
bin/kernel:     file format elf64-littleriscv


Disassembly of section .text:

ffffffffc0200000 <kern_entry>:
    .globl kern_entry
kern_entry:
    # a0: hartid
    # a1: dtb physical address
    # save hartid and dtb address
    la t0, boot_hartid
ffffffffc0200000:	00009297          	auipc	t0,0x9
ffffffffc0200004:	00028293          	mv	t0,t0
    sd a0, 0(t0)
ffffffffc0200008:	00a2b023          	sd	a0,0(t0) # ffffffffc0209000 <boot_hartid>
    la t0, boot_dtb
ffffffffc020000c:	00009297          	auipc	t0,0x9
ffffffffc0200010:	ffc28293          	addi	t0,t0,-4 # ffffffffc0209008 <boot_dtb>
    sd a1, 0(t0)
ffffffffc0200014:	00b2b023          	sd	a1,0(t0)
    
    # t0 := 三级页表的虚拟地址
    lui     t0, %hi(boot_page_table_sv39)
ffffffffc0200018:	c02082b7          	lui	t0,0xc0208
    # t1 := 0xffffffff40000000 即虚实映射偏移量
    li      t1, 0xffffffffc0000000 - 0x80000000
ffffffffc020001c:	ffd0031b          	addiw	t1,zero,-3
ffffffffc0200020:	037a                	slli	t1,t1,0x1e
    # t0 减去虚实映射偏移量 0xffffffff40000000，变为三级页表的物理地址
    sub     t0, t0, t1
ffffffffc0200022:	406282b3          	sub	t0,t0,t1
    # t0 >>= 12，变为三级页表的物理页号
    srli    t0, t0, 12
ffffffffc0200026:	00c2d293          	srli	t0,t0,0xc

    # t1 := 8 << 60，设置 satp 的 MODE 字段为 Sv39
    li      t1, 8 << 60
ffffffffc020002a:	fff0031b          	addiw	t1,zero,-1
ffffffffc020002e:	137e                	slli	t1,t1,0x3f
    # 将刚才计算出的预设三级页表物理页号附加到 satp 中
    or      t0, t0, t1
ffffffffc0200030:	0062e2b3          	or	t0,t0,t1
    # 将算出的 t0(即新的MODE|页表基址物理页号) 覆盖到 satp 中
    csrw    satp, t0
ffffffffc0200034:	18029073          	csrw	satp,t0
    # 使用 sfence.vma 指令刷新 TLB
    sfence.vma
ffffffffc0200038:	12000073          	sfence.vma
    # 从此，我们给内核搭建出了一个完美的虚拟内存空间！
    #nop # 可能映射的位置有些bug。。插入一个nop
    
    # 我们在虚拟内存空间中：随意将 sp 设置为虚拟地址！
    lui sp, %hi(bootstacktop)
ffffffffc020003c:	c0208137          	lui	sp,0xc0208

    # 我们在虚拟内存空间中：随意跳转到虚拟地址！
    # 跳转到 kern_init
    lui t0, %hi(kern_init)
ffffffffc0200040:	c02002b7          	lui	t0,0xc0200
    addi t0, t0, %lo(kern_init)
ffffffffc0200044:	04a28293          	addi	t0,t0,74 # ffffffffc020004a <kern_init>
    jr t0
ffffffffc0200048:	8282                	jr	t0

ffffffffc020004a <kern_init>:
void grade_backtrace(void);

int kern_init(void)
{
    extern char edata[], end[];
    memset(edata, 0, end - edata);
ffffffffc020004a:	00009517          	auipc	a0,0x9
ffffffffc020004e:	fe650513          	addi	a0,a0,-26 # ffffffffc0209030 <buf>
ffffffffc0200052:	0000d617          	auipc	a2,0xd
ffffffffc0200056:	49a60613          	addi	a2,a2,1178 # ffffffffc020d4ec <end>
{
ffffffffc020005a:	1141                	addi	sp,sp,-16
    memset(edata, 0, end - edata);
ffffffffc020005c:	8e09                	sub	a2,a2,a0
ffffffffc020005e:	4581                	li	a1,0
{
ffffffffc0200060:	e406                	sd	ra,8(sp)
    memset(edata, 0, end - edata);
ffffffffc0200062:	54b030ef          	jal	ra,ffffffffc0203dac <memset>
    dtb_init();
ffffffffc0200066:	514000ef          	jal	ra,ffffffffc020057a <dtb_init>
    cons_init(); // init the console
ffffffffc020006a:	49e000ef          	jal	ra,ffffffffc0200508 <cons_init>

    const char *message = "(THU.CST) os is loading ...";
    cprintf("%s\n\n", message);
ffffffffc020006e:	00004597          	auipc	a1,0x4
ffffffffc0200072:	d9258593          	addi	a1,a1,-622 # ffffffffc0203e00 <etext+0x6>
ffffffffc0200076:	00004517          	auipc	a0,0x4
ffffffffc020007a:	daa50513          	addi	a0,a0,-598 # ffffffffc0203e20 <etext+0x26>
ffffffffc020007e:	116000ef          	jal	ra,ffffffffc0200194 <cprintf>

    print_kerninfo();
ffffffffc0200082:	15a000ef          	jal	ra,ffffffffc02001dc <print_kerninfo>

    // grade_backtrace();

    pmm_init(); // init physical memory management
ffffffffc0200086:	008020ef          	jal	ra,ffffffffc020208e <pmm_init>

    pic_init(); // init interrupt controller
ffffffffc020008a:	0ad000ef          	jal	ra,ffffffffc0200936 <pic_init>
    idt_init(); // init interrupt descriptor table
ffffffffc020008e:	0ab000ef          	jal	ra,ffffffffc0200938 <idt_init>

    vmm_init();  // init virtual memory management
ffffffffc0200092:	571020ef          	jal	ra,ffffffffc0202e02 <vmm_init>
    proc_init(); // init process table
ffffffffc0200096:	4d6030ef          	jal	ra,ffffffffc020356c <proc_init>

    clock_init();  // init clock interrupt
ffffffffc020009a:	41c000ef          	jal	ra,ffffffffc02004b6 <clock_init>
    intr_enable(); // enable irq interrupt
ffffffffc020009e:	08d000ef          	jal	ra,ffffffffc020092a <intr_enable>

    cpu_idle(); // run idle process
ffffffffc02000a2:	718030ef          	jal	ra,ffffffffc02037ba <cpu_idle>

ffffffffc02000a6 <readline>:
 * The readline() function returns the text of the line read. If some errors
 * are happened, NULL is returned. The return value is a global variable,
 * thus it should be copied before it is used.
 * */
char *
readline(const char *prompt) {
ffffffffc02000a6:	715d                	addi	sp,sp,-80
ffffffffc02000a8:	e486                	sd	ra,72(sp)
ffffffffc02000aa:	e0a6                	sd	s1,64(sp)
ffffffffc02000ac:	fc4a                	sd	s2,56(sp)
ffffffffc02000ae:	f84e                	sd	s3,48(sp)
ffffffffc02000b0:	f452                	sd	s4,40(sp)
ffffffffc02000b2:	f056                	sd	s5,32(sp)
ffffffffc02000b4:	ec5a                	sd	s6,24(sp)
ffffffffc02000b6:	e85e                	sd	s7,16(sp)
    if (prompt != NULL) {
ffffffffc02000b8:	c901                	beqz	a0,ffffffffc02000c8 <readline+0x22>
ffffffffc02000ba:	85aa                	mv	a1,a0
        cprintf("%s", prompt);
ffffffffc02000bc:	00004517          	auipc	a0,0x4
ffffffffc02000c0:	d6c50513          	addi	a0,a0,-660 # ffffffffc0203e28 <etext+0x2e>
ffffffffc02000c4:	0d0000ef          	jal	ra,ffffffffc0200194 <cprintf>
readline(const char *prompt) {
ffffffffc02000c8:	4481                	li	s1,0
    while (1) {
        c = getchar();
        if (c < 0) {
            return NULL;
        }
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc02000ca:	497d                	li	s2,31
            cputchar(c);
            buf[i ++] = c;
        }
        else if (c == '\b' && i > 0) {
ffffffffc02000cc:	49a1                	li	s3,8
            cputchar(c);
            i --;
        }
        else if (c == '\n' || c == '\r') {
ffffffffc02000ce:	4aa9                	li	s5,10
ffffffffc02000d0:	4b35                	li	s6,13
            buf[i ++] = c;
ffffffffc02000d2:	00009b97          	auipc	s7,0x9
ffffffffc02000d6:	f5eb8b93          	addi	s7,s7,-162 # ffffffffc0209030 <buf>
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc02000da:	3fe00a13          	li	s4,1022
        c = getchar();
ffffffffc02000de:	0ee000ef          	jal	ra,ffffffffc02001cc <getchar>
        if (c < 0) {
ffffffffc02000e2:	00054a63          	bltz	a0,ffffffffc02000f6 <readline+0x50>
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc02000e6:	00a95a63          	bge	s2,a0,ffffffffc02000fa <readline+0x54>
ffffffffc02000ea:	029a5263          	bge	s4,s1,ffffffffc020010e <readline+0x68>
        c = getchar();
ffffffffc02000ee:	0de000ef          	jal	ra,ffffffffc02001cc <getchar>
        if (c < 0) {
ffffffffc02000f2:	fe055ae3          	bgez	a0,ffffffffc02000e6 <readline+0x40>
            return NULL;
ffffffffc02000f6:	4501                	li	a0,0
ffffffffc02000f8:	a091                	j	ffffffffc020013c <readline+0x96>
        else if (c == '\b' && i > 0) {
ffffffffc02000fa:	03351463          	bne	a0,s3,ffffffffc0200122 <readline+0x7c>
ffffffffc02000fe:	e8a9                	bnez	s1,ffffffffc0200150 <readline+0xaa>
        c = getchar();
ffffffffc0200100:	0cc000ef          	jal	ra,ffffffffc02001cc <getchar>
        if (c < 0) {
ffffffffc0200104:	fe0549e3          	bltz	a0,ffffffffc02000f6 <readline+0x50>
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc0200108:	fea959e3          	bge	s2,a0,ffffffffc02000fa <readline+0x54>
ffffffffc020010c:	4481                	li	s1,0
            cputchar(c);
ffffffffc020010e:	e42a                	sd	a0,8(sp)
ffffffffc0200110:	0ba000ef          	jal	ra,ffffffffc02001ca <cputchar>
            buf[i ++] = c;
ffffffffc0200114:	6522                	ld	a0,8(sp)
ffffffffc0200116:	009b87b3          	add	a5,s7,s1
ffffffffc020011a:	2485                	addiw	s1,s1,1
ffffffffc020011c:	00a78023          	sb	a0,0(a5)
ffffffffc0200120:	bf7d                	j	ffffffffc02000de <readline+0x38>
        else if (c == '\n' || c == '\r') {
ffffffffc0200122:	01550463          	beq	a0,s5,ffffffffc020012a <readline+0x84>
ffffffffc0200126:	fb651ce3          	bne	a0,s6,ffffffffc02000de <readline+0x38>
            cputchar(c);
ffffffffc020012a:	0a0000ef          	jal	ra,ffffffffc02001ca <cputchar>
            buf[i] = '\0';
ffffffffc020012e:	00009517          	auipc	a0,0x9
ffffffffc0200132:	f0250513          	addi	a0,a0,-254 # ffffffffc0209030 <buf>
ffffffffc0200136:	94aa                	add	s1,s1,a0
ffffffffc0200138:	00048023          	sb	zero,0(s1)
            return buf;
        }
    }
}
ffffffffc020013c:	60a6                	ld	ra,72(sp)
ffffffffc020013e:	6486                	ld	s1,64(sp)
ffffffffc0200140:	7962                	ld	s2,56(sp)
ffffffffc0200142:	79c2                	ld	s3,48(sp)
ffffffffc0200144:	7a22                	ld	s4,40(sp)
ffffffffc0200146:	7a82                	ld	s5,32(sp)
ffffffffc0200148:	6b62                	ld	s6,24(sp)
ffffffffc020014a:	6bc2                	ld	s7,16(sp)
ffffffffc020014c:	6161                	addi	sp,sp,80
ffffffffc020014e:	8082                	ret
            cputchar(c);
ffffffffc0200150:	4521                	li	a0,8
ffffffffc0200152:	078000ef          	jal	ra,ffffffffc02001ca <cputchar>
            i --;
ffffffffc0200156:	34fd                	addiw	s1,s1,-1
ffffffffc0200158:	b759                	j	ffffffffc02000de <readline+0x38>

ffffffffc020015a <cputch>:
 * cputch - writes a single character @c to stdout, and it will
 * increace the value of counter pointed by @cnt.
 * */
static void
cputch(int c, int *cnt)
{
ffffffffc020015a:	1141                	addi	sp,sp,-16
ffffffffc020015c:	e022                	sd	s0,0(sp)
ffffffffc020015e:	e406                	sd	ra,8(sp)
ffffffffc0200160:	842e                	mv	s0,a1
    cons_putc(c);
ffffffffc0200162:	3a8000ef          	jal	ra,ffffffffc020050a <cons_putc>
    (*cnt)++;
ffffffffc0200166:	401c                	lw	a5,0(s0)
}
ffffffffc0200168:	60a2                	ld	ra,8(sp)
    (*cnt)++;
ffffffffc020016a:	2785                	addiw	a5,a5,1
ffffffffc020016c:	c01c                	sw	a5,0(s0)
}
ffffffffc020016e:	6402                	ld	s0,0(sp)
ffffffffc0200170:	0141                	addi	sp,sp,16
ffffffffc0200172:	8082                	ret

ffffffffc0200174 <vcprintf>:
 *
 * Call this function if you are already dealing with a va_list.
 * Or you probably want cprintf() instead.
 * */
int vcprintf(const char *fmt, va_list ap)
{
ffffffffc0200174:	1101                	addi	sp,sp,-32
ffffffffc0200176:	862a                	mv	a2,a0
ffffffffc0200178:	86ae                	mv	a3,a1
    int cnt = 0;
    vprintfmt((void *)cputch, &cnt, fmt, ap);
ffffffffc020017a:	00000517          	auipc	a0,0x0
ffffffffc020017e:	fe050513          	addi	a0,a0,-32 # ffffffffc020015a <cputch>
ffffffffc0200182:	006c                	addi	a1,sp,12
{
ffffffffc0200184:	ec06                	sd	ra,24(sp)
    int cnt = 0;
ffffffffc0200186:	c602                	sw	zero,12(sp)
    vprintfmt((void *)cputch, &cnt, fmt, ap);
ffffffffc0200188:	001030ef          	jal	ra,ffffffffc0203988 <vprintfmt>
    return cnt;
}
ffffffffc020018c:	60e2                	ld	ra,24(sp)
ffffffffc020018e:	4532                	lw	a0,12(sp)
ffffffffc0200190:	6105                	addi	sp,sp,32
ffffffffc0200192:	8082                	ret

ffffffffc0200194 <cprintf>:
 *
 * The return value is the number of characters which would be
 * written to stdout.
 * */
int cprintf(const char *fmt, ...)
{
ffffffffc0200194:	711d                	addi	sp,sp,-96
    va_list ap;
    int cnt;
    va_start(ap, fmt);
ffffffffc0200196:	02810313          	addi	t1,sp,40 # ffffffffc0208028 <boot_page_table_sv39+0x28>
{
ffffffffc020019a:	8e2a                	mv	t3,a0
ffffffffc020019c:	f42e                	sd	a1,40(sp)
ffffffffc020019e:	f832                	sd	a2,48(sp)
ffffffffc02001a0:	fc36                	sd	a3,56(sp)
    vprintfmt((void *)cputch, &cnt, fmt, ap);
ffffffffc02001a2:	00000517          	auipc	a0,0x0
ffffffffc02001a6:	fb850513          	addi	a0,a0,-72 # ffffffffc020015a <cputch>
ffffffffc02001aa:	004c                	addi	a1,sp,4
ffffffffc02001ac:	869a                	mv	a3,t1
ffffffffc02001ae:	8672                	mv	a2,t3
{
ffffffffc02001b0:	ec06                	sd	ra,24(sp)
ffffffffc02001b2:	e0ba                	sd	a4,64(sp)
ffffffffc02001b4:	e4be                	sd	a5,72(sp)
ffffffffc02001b6:	e8c2                	sd	a6,80(sp)
ffffffffc02001b8:	ecc6                	sd	a7,88(sp)
    va_start(ap, fmt);
ffffffffc02001ba:	e41a                	sd	t1,8(sp)
    int cnt = 0;
ffffffffc02001bc:	c202                	sw	zero,4(sp)
    vprintfmt((void *)cputch, &cnt, fmt, ap);
ffffffffc02001be:	7ca030ef          	jal	ra,ffffffffc0203988 <vprintfmt>
    cnt = vcprintf(fmt, ap);
    va_end(ap);
    return cnt;
}
ffffffffc02001c2:	60e2                	ld	ra,24(sp)
ffffffffc02001c4:	4512                	lw	a0,4(sp)
ffffffffc02001c6:	6125                	addi	sp,sp,96
ffffffffc02001c8:	8082                	ret

ffffffffc02001ca <cputchar>:

/* cputchar - writes a single character to stdout */
void cputchar(int c)
{
    cons_putc(c);
ffffffffc02001ca:	a681                	j	ffffffffc020050a <cons_putc>

ffffffffc02001cc <getchar>:
}

/* getchar - reads a single non-zero character from stdin */
int getchar(void)
{
ffffffffc02001cc:	1141                	addi	sp,sp,-16
ffffffffc02001ce:	e406                	sd	ra,8(sp)
    int c;
    while ((c = cons_getc()) == 0)
ffffffffc02001d0:	36e000ef          	jal	ra,ffffffffc020053e <cons_getc>
ffffffffc02001d4:	dd75                	beqz	a0,ffffffffc02001d0 <getchar+0x4>
        /* do nothing */;
    return c;
}
ffffffffc02001d6:	60a2                	ld	ra,8(sp)
ffffffffc02001d8:	0141                	addi	sp,sp,16
ffffffffc02001da:	8082                	ret

ffffffffc02001dc <print_kerninfo>:
 * print_kerninfo - print the information about kernel, including the location
 * of kernel entry, the start addresses of data and text segements, the start
 * address of free memory and how many memory that kernel has used.
 * */
void print_kerninfo(void)
{
ffffffffc02001dc:	1141                	addi	sp,sp,-16
    extern char etext[], edata[], end[], kern_init[];
    cprintf("Special kernel symbols:\n");
ffffffffc02001de:	00004517          	auipc	a0,0x4
ffffffffc02001e2:	c5250513          	addi	a0,a0,-942 # ffffffffc0203e30 <etext+0x36>
{
ffffffffc02001e6:	e406                	sd	ra,8(sp)
    cprintf("Special kernel symbols:\n");
ffffffffc02001e8:	fadff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  entry  0x%08x (virtual)\n", kern_init);
ffffffffc02001ec:	00000597          	auipc	a1,0x0
ffffffffc02001f0:	e5e58593          	addi	a1,a1,-418 # ffffffffc020004a <kern_init>
ffffffffc02001f4:	00004517          	auipc	a0,0x4
ffffffffc02001f8:	c5c50513          	addi	a0,a0,-932 # ffffffffc0203e50 <etext+0x56>
ffffffffc02001fc:	f99ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  etext  0x%08x (virtual)\n", etext);
ffffffffc0200200:	00004597          	auipc	a1,0x4
ffffffffc0200204:	bfa58593          	addi	a1,a1,-1030 # ffffffffc0203dfa <etext>
ffffffffc0200208:	00004517          	auipc	a0,0x4
ffffffffc020020c:	c6850513          	addi	a0,a0,-920 # ffffffffc0203e70 <etext+0x76>
ffffffffc0200210:	f85ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  edata  0x%08x (virtual)\n", edata);
ffffffffc0200214:	00009597          	auipc	a1,0x9
ffffffffc0200218:	e1c58593          	addi	a1,a1,-484 # ffffffffc0209030 <buf>
ffffffffc020021c:	00004517          	auipc	a0,0x4
ffffffffc0200220:	c7450513          	addi	a0,a0,-908 # ffffffffc0203e90 <etext+0x96>
ffffffffc0200224:	f71ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  end    0x%08x (virtual)\n", end);
ffffffffc0200228:	0000d597          	auipc	a1,0xd
ffffffffc020022c:	2c458593          	addi	a1,a1,708 # ffffffffc020d4ec <end>
ffffffffc0200230:	00004517          	auipc	a0,0x4
ffffffffc0200234:	c8050513          	addi	a0,a0,-896 # ffffffffc0203eb0 <etext+0xb6>
ffffffffc0200238:	f5dff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("Kernel executable memory footprint: %dKB\n",
            (end - kern_init + 1023) / 1024);
ffffffffc020023c:	0000d597          	auipc	a1,0xd
ffffffffc0200240:	6af58593          	addi	a1,a1,1711 # ffffffffc020d8eb <end+0x3ff>
ffffffffc0200244:	00000797          	auipc	a5,0x0
ffffffffc0200248:	e0678793          	addi	a5,a5,-506 # ffffffffc020004a <kern_init>
ffffffffc020024c:	40f587b3          	sub	a5,a1,a5
    cprintf("Kernel executable memory footprint: %dKB\n",
ffffffffc0200250:	43f7d593          	srai	a1,a5,0x3f
}
ffffffffc0200254:	60a2                	ld	ra,8(sp)
    cprintf("Kernel executable memory footprint: %dKB\n",
ffffffffc0200256:	3ff5f593          	andi	a1,a1,1023
ffffffffc020025a:	95be                	add	a1,a1,a5
ffffffffc020025c:	85a9                	srai	a1,a1,0xa
ffffffffc020025e:	00004517          	auipc	a0,0x4
ffffffffc0200262:	c7250513          	addi	a0,a0,-910 # ffffffffc0203ed0 <etext+0xd6>
}
ffffffffc0200266:	0141                	addi	sp,sp,16
    cprintf("Kernel executable memory footprint: %dKB\n",
ffffffffc0200268:	b735                	j	ffffffffc0200194 <cprintf>

ffffffffc020026a <print_stackframe>:
 * jumping
 * to the kernel entry, the value of ebp has been set to zero, that's the
 * boundary.
 * */
void print_stackframe(void)
{
ffffffffc020026a:	1141                	addi	sp,sp,-16
    panic("Not Implemented!");
ffffffffc020026c:	00004617          	auipc	a2,0x4
ffffffffc0200270:	c9460613          	addi	a2,a2,-876 # ffffffffc0203f00 <etext+0x106>
ffffffffc0200274:	04900593          	li	a1,73
ffffffffc0200278:	00004517          	auipc	a0,0x4
ffffffffc020027c:	ca050513          	addi	a0,a0,-864 # ffffffffc0203f18 <etext+0x11e>
{
ffffffffc0200280:	e406                	sd	ra,8(sp)
    panic("Not Implemented!");
ffffffffc0200282:	1d8000ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0200286 <mon_help>:
    }
}

/* mon_help - print the information about mon_* functions */
int
mon_help(int argc, char **argv, struct trapframe *tf) {
ffffffffc0200286:	1141                	addi	sp,sp,-16
    int i;
    for (i = 0; i < NCOMMANDS; i ++) {
        cprintf("%s - %s\n", commands[i].name, commands[i].desc);
ffffffffc0200288:	00004617          	auipc	a2,0x4
ffffffffc020028c:	ca860613          	addi	a2,a2,-856 # ffffffffc0203f30 <etext+0x136>
ffffffffc0200290:	00004597          	auipc	a1,0x4
ffffffffc0200294:	cc058593          	addi	a1,a1,-832 # ffffffffc0203f50 <etext+0x156>
ffffffffc0200298:	00004517          	auipc	a0,0x4
ffffffffc020029c:	cc050513          	addi	a0,a0,-832 # ffffffffc0203f58 <etext+0x15e>
mon_help(int argc, char **argv, struct trapframe *tf) {
ffffffffc02002a0:	e406                	sd	ra,8(sp)
        cprintf("%s - %s\n", commands[i].name, commands[i].desc);
ffffffffc02002a2:	ef3ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
ffffffffc02002a6:	00004617          	auipc	a2,0x4
ffffffffc02002aa:	cc260613          	addi	a2,a2,-830 # ffffffffc0203f68 <etext+0x16e>
ffffffffc02002ae:	00004597          	auipc	a1,0x4
ffffffffc02002b2:	ce258593          	addi	a1,a1,-798 # ffffffffc0203f90 <etext+0x196>
ffffffffc02002b6:	00004517          	auipc	a0,0x4
ffffffffc02002ba:	ca250513          	addi	a0,a0,-862 # ffffffffc0203f58 <etext+0x15e>
ffffffffc02002be:	ed7ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
ffffffffc02002c2:	00004617          	auipc	a2,0x4
ffffffffc02002c6:	cde60613          	addi	a2,a2,-802 # ffffffffc0203fa0 <etext+0x1a6>
ffffffffc02002ca:	00004597          	auipc	a1,0x4
ffffffffc02002ce:	cf658593          	addi	a1,a1,-778 # ffffffffc0203fc0 <etext+0x1c6>
ffffffffc02002d2:	00004517          	auipc	a0,0x4
ffffffffc02002d6:	c8650513          	addi	a0,a0,-890 # ffffffffc0203f58 <etext+0x15e>
ffffffffc02002da:	ebbff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    }
    return 0;
}
ffffffffc02002de:	60a2                	ld	ra,8(sp)
ffffffffc02002e0:	4501                	li	a0,0
ffffffffc02002e2:	0141                	addi	sp,sp,16
ffffffffc02002e4:	8082                	ret

ffffffffc02002e6 <mon_kerninfo>:
/* *
 * mon_kerninfo - call print_kerninfo in kern/debug/kdebug.c to
 * print the memory occupancy in kernel.
 * */
int
mon_kerninfo(int argc, char **argv, struct trapframe *tf) {
ffffffffc02002e6:	1141                	addi	sp,sp,-16
ffffffffc02002e8:	e406                	sd	ra,8(sp)
    print_kerninfo();
ffffffffc02002ea:	ef3ff0ef          	jal	ra,ffffffffc02001dc <print_kerninfo>
    return 0;
}
ffffffffc02002ee:	60a2                	ld	ra,8(sp)
ffffffffc02002f0:	4501                	li	a0,0
ffffffffc02002f2:	0141                	addi	sp,sp,16
ffffffffc02002f4:	8082                	ret

ffffffffc02002f6 <mon_backtrace>:
/* *
 * mon_backtrace - call print_stackframe in kern/debug/kdebug.c to
 * print a backtrace of the stack.
 * */
int
mon_backtrace(int argc, char **argv, struct trapframe *tf) {
ffffffffc02002f6:	1141                	addi	sp,sp,-16
ffffffffc02002f8:	e406                	sd	ra,8(sp)
    print_stackframe();
ffffffffc02002fa:	f71ff0ef          	jal	ra,ffffffffc020026a <print_stackframe>
    return 0;
}
ffffffffc02002fe:	60a2                	ld	ra,8(sp)
ffffffffc0200300:	4501                	li	a0,0
ffffffffc0200302:	0141                	addi	sp,sp,16
ffffffffc0200304:	8082                	ret

ffffffffc0200306 <kmonitor>:
kmonitor(struct trapframe *tf) {
ffffffffc0200306:	7115                	addi	sp,sp,-224
ffffffffc0200308:	ed5e                	sd	s7,152(sp)
ffffffffc020030a:	8baa                	mv	s7,a0
    cprintf("Welcome to the kernel debug monitor!!\n");
ffffffffc020030c:	00004517          	auipc	a0,0x4
ffffffffc0200310:	cc450513          	addi	a0,a0,-828 # ffffffffc0203fd0 <etext+0x1d6>
kmonitor(struct trapframe *tf) {
ffffffffc0200314:	ed86                	sd	ra,216(sp)
ffffffffc0200316:	e9a2                	sd	s0,208(sp)
ffffffffc0200318:	e5a6                	sd	s1,200(sp)
ffffffffc020031a:	e1ca                	sd	s2,192(sp)
ffffffffc020031c:	fd4e                	sd	s3,184(sp)
ffffffffc020031e:	f952                	sd	s4,176(sp)
ffffffffc0200320:	f556                	sd	s5,168(sp)
ffffffffc0200322:	f15a                	sd	s6,160(sp)
ffffffffc0200324:	e962                	sd	s8,144(sp)
ffffffffc0200326:	e566                	sd	s9,136(sp)
ffffffffc0200328:	e16a                	sd	s10,128(sp)
    cprintf("Welcome to the kernel debug monitor!!\n");
ffffffffc020032a:	e6bff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("Type 'help' for a list of commands.\n");
ffffffffc020032e:	00004517          	auipc	a0,0x4
ffffffffc0200332:	cca50513          	addi	a0,a0,-822 # ffffffffc0203ff8 <etext+0x1fe>
ffffffffc0200336:	e5fff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    if (tf != NULL) {
ffffffffc020033a:	000b8563          	beqz	s7,ffffffffc0200344 <kmonitor+0x3e>
        print_trapframe(tf);
ffffffffc020033e:	855e                	mv	a0,s7
ffffffffc0200340:	7e0000ef          	jal	ra,ffffffffc0200b20 <print_trapframe>
#endif
}

static inline void sbi_shutdown(void)
{
	SBI_CALL_0(SBI_SHUTDOWN);
ffffffffc0200344:	4501                	li	a0,0
ffffffffc0200346:	4581                	li	a1,0
ffffffffc0200348:	4601                	li	a2,0
ffffffffc020034a:	48a1                	li	a7,8
ffffffffc020034c:	00000073          	ecall
ffffffffc0200350:	00004c17          	auipc	s8,0x4
ffffffffc0200354:	d18c0c13          	addi	s8,s8,-744 # ffffffffc0204068 <commands>
        if ((buf = readline("K> ")) != NULL) {
ffffffffc0200358:	00004917          	auipc	s2,0x4
ffffffffc020035c:	cc890913          	addi	s2,s2,-824 # ffffffffc0204020 <etext+0x226>
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc0200360:	00004497          	auipc	s1,0x4
ffffffffc0200364:	cc848493          	addi	s1,s1,-824 # ffffffffc0204028 <etext+0x22e>
        if (argc == MAXARGS - 1) {
ffffffffc0200368:	49bd                	li	s3,15
            cprintf("Too many arguments (max %d).\n", MAXARGS);
ffffffffc020036a:	00004b17          	auipc	s6,0x4
ffffffffc020036e:	cc6b0b13          	addi	s6,s6,-826 # ffffffffc0204030 <etext+0x236>
        argv[argc ++] = buf;
ffffffffc0200372:	00004a17          	auipc	s4,0x4
ffffffffc0200376:	bdea0a13          	addi	s4,s4,-1058 # ffffffffc0203f50 <etext+0x156>
    for (i = 0; i < NCOMMANDS; i ++) {
ffffffffc020037a:	4a8d                	li	s5,3
        if ((buf = readline("K> ")) != NULL) {
ffffffffc020037c:	854a                	mv	a0,s2
ffffffffc020037e:	d29ff0ef          	jal	ra,ffffffffc02000a6 <readline>
ffffffffc0200382:	842a                	mv	s0,a0
ffffffffc0200384:	dd65                	beqz	a0,ffffffffc020037c <kmonitor+0x76>
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc0200386:	00054583          	lbu	a1,0(a0)
    int argc = 0;
ffffffffc020038a:	4c81                	li	s9,0
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc020038c:	e1bd                	bnez	a1,ffffffffc02003f2 <kmonitor+0xec>
    if (argc == 0) {
ffffffffc020038e:	fe0c87e3          	beqz	s9,ffffffffc020037c <kmonitor+0x76>
        if (strcmp(commands[i].name, argv[0]) == 0) {
ffffffffc0200392:	6582                	ld	a1,0(sp)
ffffffffc0200394:	00004d17          	auipc	s10,0x4
ffffffffc0200398:	cd4d0d13          	addi	s10,s10,-812 # ffffffffc0204068 <commands>
        argv[argc ++] = buf;
ffffffffc020039c:	8552                	mv	a0,s4
    for (i = 0; i < NCOMMANDS; i ++) {
ffffffffc020039e:	4401                	li	s0,0
ffffffffc02003a0:	0d61                	addi	s10,s10,24
        if (strcmp(commands[i].name, argv[0]) == 0) {
ffffffffc02003a2:	1b1030ef          	jal	ra,ffffffffc0203d52 <strcmp>
ffffffffc02003a6:	c919                	beqz	a0,ffffffffc02003bc <kmonitor+0xb6>
    for (i = 0; i < NCOMMANDS; i ++) {
ffffffffc02003a8:	2405                	addiw	s0,s0,1
ffffffffc02003aa:	0b540063          	beq	s0,s5,ffffffffc020044a <kmonitor+0x144>
        if (strcmp(commands[i].name, argv[0]) == 0) {
ffffffffc02003ae:	000d3503          	ld	a0,0(s10)
ffffffffc02003b2:	6582                	ld	a1,0(sp)
    for (i = 0; i < NCOMMANDS; i ++) {
ffffffffc02003b4:	0d61                	addi	s10,s10,24
        if (strcmp(commands[i].name, argv[0]) == 0) {
ffffffffc02003b6:	19d030ef          	jal	ra,ffffffffc0203d52 <strcmp>
ffffffffc02003ba:	f57d                	bnez	a0,ffffffffc02003a8 <kmonitor+0xa2>
            return commands[i].func(argc - 1, argv + 1, tf);
ffffffffc02003bc:	00141793          	slli	a5,s0,0x1
ffffffffc02003c0:	97a2                	add	a5,a5,s0
ffffffffc02003c2:	078e                	slli	a5,a5,0x3
ffffffffc02003c4:	97e2                	add	a5,a5,s8
ffffffffc02003c6:	6b9c                	ld	a5,16(a5)
ffffffffc02003c8:	865e                	mv	a2,s7
ffffffffc02003ca:	002c                	addi	a1,sp,8
ffffffffc02003cc:	fffc851b          	addiw	a0,s9,-1
ffffffffc02003d0:	9782                	jalr	a5
            if (runcmd(buf, tf) < 0) {
ffffffffc02003d2:	fa0555e3          	bgez	a0,ffffffffc020037c <kmonitor+0x76>
}
ffffffffc02003d6:	60ee                	ld	ra,216(sp)
ffffffffc02003d8:	644e                	ld	s0,208(sp)
ffffffffc02003da:	64ae                	ld	s1,200(sp)
ffffffffc02003dc:	690e                	ld	s2,192(sp)
ffffffffc02003de:	79ea                	ld	s3,184(sp)
ffffffffc02003e0:	7a4a                	ld	s4,176(sp)
ffffffffc02003e2:	7aaa                	ld	s5,168(sp)
ffffffffc02003e4:	7b0a                	ld	s6,160(sp)
ffffffffc02003e6:	6bea                	ld	s7,152(sp)
ffffffffc02003e8:	6c4a                	ld	s8,144(sp)
ffffffffc02003ea:	6caa                	ld	s9,136(sp)
ffffffffc02003ec:	6d0a                	ld	s10,128(sp)
ffffffffc02003ee:	612d                	addi	sp,sp,224
ffffffffc02003f0:	8082                	ret
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc02003f2:	8526                	mv	a0,s1
ffffffffc02003f4:	1a3030ef          	jal	ra,ffffffffc0203d96 <strchr>
ffffffffc02003f8:	c901                	beqz	a0,ffffffffc0200408 <kmonitor+0x102>
ffffffffc02003fa:	00144583          	lbu	a1,1(s0)
            *buf ++ = '\0';
ffffffffc02003fe:	00040023          	sb	zero,0(s0)
ffffffffc0200402:	0405                	addi	s0,s0,1
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc0200404:	d5c9                	beqz	a1,ffffffffc020038e <kmonitor+0x88>
ffffffffc0200406:	b7f5                	j	ffffffffc02003f2 <kmonitor+0xec>
        if (*buf == '\0') {
ffffffffc0200408:	00044783          	lbu	a5,0(s0)
ffffffffc020040c:	d3c9                	beqz	a5,ffffffffc020038e <kmonitor+0x88>
        if (argc == MAXARGS - 1) {
ffffffffc020040e:	033c8963          	beq	s9,s3,ffffffffc0200440 <kmonitor+0x13a>
        argv[argc ++] = buf;
ffffffffc0200412:	003c9793          	slli	a5,s9,0x3
ffffffffc0200416:	0118                	addi	a4,sp,128
ffffffffc0200418:	97ba                	add	a5,a5,a4
ffffffffc020041a:	f887b023          	sd	s0,-128(a5)
        while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
ffffffffc020041e:	00044583          	lbu	a1,0(s0)
        argv[argc ++] = buf;
ffffffffc0200422:	2c85                	addiw	s9,s9,1
        while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
ffffffffc0200424:	e591                	bnez	a1,ffffffffc0200430 <kmonitor+0x12a>
ffffffffc0200426:	b7b5                	j	ffffffffc0200392 <kmonitor+0x8c>
ffffffffc0200428:	00144583          	lbu	a1,1(s0)
            buf ++;
ffffffffc020042c:	0405                	addi	s0,s0,1
        while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
ffffffffc020042e:	d1a5                	beqz	a1,ffffffffc020038e <kmonitor+0x88>
ffffffffc0200430:	8526                	mv	a0,s1
ffffffffc0200432:	165030ef          	jal	ra,ffffffffc0203d96 <strchr>
ffffffffc0200436:	d96d                	beqz	a0,ffffffffc0200428 <kmonitor+0x122>
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc0200438:	00044583          	lbu	a1,0(s0)
ffffffffc020043c:	d9a9                	beqz	a1,ffffffffc020038e <kmonitor+0x88>
ffffffffc020043e:	bf55                	j	ffffffffc02003f2 <kmonitor+0xec>
            cprintf("Too many arguments (max %d).\n", MAXARGS);
ffffffffc0200440:	45c1                	li	a1,16
ffffffffc0200442:	855a                	mv	a0,s6
ffffffffc0200444:	d51ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
ffffffffc0200448:	b7e9                	j	ffffffffc0200412 <kmonitor+0x10c>
    cprintf("Unknown command '%s'\n", argv[0]);
ffffffffc020044a:	6582                	ld	a1,0(sp)
ffffffffc020044c:	00004517          	auipc	a0,0x4
ffffffffc0200450:	c0450513          	addi	a0,a0,-1020 # ffffffffc0204050 <etext+0x256>
ffffffffc0200454:	d41ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    return 0;
ffffffffc0200458:	b715                	j	ffffffffc020037c <kmonitor+0x76>

ffffffffc020045a <__panic>:
 * __panic - __panic is called on unresolvable fatal errors. it prints
 * "panic: 'message'", and then enters the kernel monitor.
 * */
void
__panic(const char *file, int line, const char *fmt, ...) {
    if (is_panic) {
ffffffffc020045a:	0000d317          	auipc	t1,0xd
ffffffffc020045e:	00e30313          	addi	t1,t1,14 # ffffffffc020d468 <is_panic>
ffffffffc0200462:	00032e03          	lw	t3,0(t1)
__panic(const char *file, int line, const char *fmt, ...) {
ffffffffc0200466:	715d                	addi	sp,sp,-80
ffffffffc0200468:	ec06                	sd	ra,24(sp)
ffffffffc020046a:	e822                	sd	s0,16(sp)
ffffffffc020046c:	f436                	sd	a3,40(sp)
ffffffffc020046e:	f83a                	sd	a4,48(sp)
ffffffffc0200470:	fc3e                	sd	a5,56(sp)
ffffffffc0200472:	e0c2                	sd	a6,64(sp)
ffffffffc0200474:	e4c6                	sd	a7,72(sp)
    if (is_panic) {
ffffffffc0200476:	020e1a63          	bnez	t3,ffffffffc02004aa <__panic+0x50>
        goto panic_dead;
    }
    is_panic = 1;
ffffffffc020047a:	4785                	li	a5,1
ffffffffc020047c:	00f32023          	sw	a5,0(t1)

    // print the 'message'
    va_list ap;
    va_start(ap, fmt);
ffffffffc0200480:	8432                	mv	s0,a2
ffffffffc0200482:	103c                	addi	a5,sp,40
    cprintf("kernel panic at %s:%d:\n    ", file, line);
ffffffffc0200484:	862e                	mv	a2,a1
ffffffffc0200486:	85aa                	mv	a1,a0
ffffffffc0200488:	00004517          	auipc	a0,0x4
ffffffffc020048c:	c2850513          	addi	a0,a0,-984 # ffffffffc02040b0 <commands+0x48>
    va_start(ap, fmt);
ffffffffc0200490:	e43e                	sd	a5,8(sp)
    cprintf("kernel panic at %s:%d:\n    ", file, line);
ffffffffc0200492:	d03ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    vcprintf(fmt, ap);
ffffffffc0200496:	65a2                	ld	a1,8(sp)
ffffffffc0200498:	8522                	mv	a0,s0
ffffffffc020049a:	cdbff0ef          	jal	ra,ffffffffc0200174 <vcprintf>
    cprintf("\n");
ffffffffc020049e:	00005517          	auipc	a0,0x5
ffffffffc02004a2:	c4a50513          	addi	a0,a0,-950 # ffffffffc02050e8 <best_fit_pmm_manager+0x530>
ffffffffc02004a6:	cefff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    va_end(ap);

panic_dead:
    intr_disable();
ffffffffc02004aa:	486000ef          	jal	ra,ffffffffc0200930 <intr_disable>
    while (1) {
        kmonitor(NULL);
ffffffffc02004ae:	4501                	li	a0,0
ffffffffc02004b0:	e57ff0ef          	jal	ra,ffffffffc0200306 <kmonitor>
    while (1) {
ffffffffc02004b4:	bfed                	j	ffffffffc02004ae <__panic+0x54>

ffffffffc02004b6 <clock_init>:
 * and then enable IRQ_TIMER.
 * */
void clock_init(void) {
    // divided by 500 when using Spike(2MHz)
    // divided by 100 when using QEMU(10MHz)
    timebase = 1e7 / 100;
ffffffffc02004b6:	67e1                	lui	a5,0x18
ffffffffc02004b8:	6a078793          	addi	a5,a5,1696 # 186a0 <kern_entry-0xffffffffc01e7960>
ffffffffc02004bc:	0000d717          	auipc	a4,0xd
ffffffffc02004c0:	faf73e23          	sd	a5,-68(a4) # ffffffffc020d478 <timebase>
    __asm__ __volatile__("rdtime %0" : "=r"(n));
ffffffffc02004c4:	c0102573          	rdtime	a0
	SBI_CALL_1(SBI_SET_TIMER, stime_value);
ffffffffc02004c8:	4581                	li	a1,0
    ticks = 0;

    cprintf("++ setup timer interrupts\n");
}

void clock_set_next_event(void) { sbi_set_timer(get_cycles() + timebase); }
ffffffffc02004ca:	953e                	add	a0,a0,a5
ffffffffc02004cc:	4601                	li	a2,0
ffffffffc02004ce:	4881                	li	a7,0
ffffffffc02004d0:	00000073          	ecall
    set_csr(sie, MIP_STIP);
ffffffffc02004d4:	02000793          	li	a5,32
ffffffffc02004d8:	1047a7f3          	csrrs	a5,sie,a5
    cprintf("++ setup timer interrupts\n");
ffffffffc02004dc:	00004517          	auipc	a0,0x4
ffffffffc02004e0:	bf450513          	addi	a0,a0,-1036 # ffffffffc02040d0 <commands+0x68>
    ticks = 0;
ffffffffc02004e4:	0000d797          	auipc	a5,0xd
ffffffffc02004e8:	f807b623          	sd	zero,-116(a5) # ffffffffc020d470 <ticks>
    cprintf("++ setup timer interrupts\n");
ffffffffc02004ec:	b165                	j	ffffffffc0200194 <cprintf>

ffffffffc02004ee <clock_set_next_event>:
    __asm__ __volatile__("rdtime %0" : "=r"(n));
ffffffffc02004ee:	c0102573          	rdtime	a0
void clock_set_next_event(void) { sbi_set_timer(get_cycles() + timebase); }
ffffffffc02004f2:	0000d797          	auipc	a5,0xd
ffffffffc02004f6:	f867b783          	ld	a5,-122(a5) # ffffffffc020d478 <timebase>
ffffffffc02004fa:	953e                	add	a0,a0,a5
ffffffffc02004fc:	4581                	li	a1,0
ffffffffc02004fe:	4601                	li	a2,0
ffffffffc0200500:	4881                	li	a7,0
ffffffffc0200502:	00000073          	ecall
ffffffffc0200506:	8082                	ret

ffffffffc0200508 <cons_init>:

/* serial_intr - try to feed input characters from serial port */
void serial_intr(void) {}

/* cons_init - initializes the console devices */
void cons_init(void) {}
ffffffffc0200508:	8082                	ret

ffffffffc020050a <cons_putc>:
#include <defs.h>
#include <intr.h>
#include <riscv.h>

static inline bool __intr_save(void) {
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc020050a:	100027f3          	csrr	a5,sstatus
ffffffffc020050e:	8b89                	andi	a5,a5,2
	SBI_CALL_1(SBI_CONSOLE_PUTCHAR, ch);
ffffffffc0200510:	0ff57513          	zext.b	a0,a0
ffffffffc0200514:	e799                	bnez	a5,ffffffffc0200522 <cons_putc+0x18>
ffffffffc0200516:	4581                	li	a1,0
ffffffffc0200518:	4601                	li	a2,0
ffffffffc020051a:	4885                	li	a7,1
ffffffffc020051c:	00000073          	ecall
    }
    return 0;
}

static inline void __intr_restore(bool flag) {
    if (flag) {
ffffffffc0200520:	8082                	ret

/* cons_putc - print a single character @c to console devices */
void cons_putc(int c) {
ffffffffc0200522:	1101                	addi	sp,sp,-32
ffffffffc0200524:	ec06                	sd	ra,24(sp)
ffffffffc0200526:	e42a                	sd	a0,8(sp)
        intr_disable();
ffffffffc0200528:	408000ef          	jal	ra,ffffffffc0200930 <intr_disable>
ffffffffc020052c:	6522                	ld	a0,8(sp)
ffffffffc020052e:	4581                	li	a1,0
ffffffffc0200530:	4601                	li	a2,0
ffffffffc0200532:	4885                	li	a7,1
ffffffffc0200534:	00000073          	ecall
    local_intr_save(intr_flag);
    {
        sbi_console_putchar((unsigned char)c);
    }
    local_intr_restore(intr_flag);
}
ffffffffc0200538:	60e2                	ld	ra,24(sp)
ffffffffc020053a:	6105                	addi	sp,sp,32
        intr_enable();
ffffffffc020053c:	a6fd                	j	ffffffffc020092a <intr_enable>

ffffffffc020053e <cons_getc>:
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc020053e:	100027f3          	csrr	a5,sstatus
ffffffffc0200542:	8b89                	andi	a5,a5,2
ffffffffc0200544:	eb89                	bnez	a5,ffffffffc0200556 <cons_getc+0x18>
	return SBI_CALL_0(SBI_CONSOLE_GETCHAR);
ffffffffc0200546:	4501                	li	a0,0
ffffffffc0200548:	4581                	li	a1,0
ffffffffc020054a:	4601                	li	a2,0
ffffffffc020054c:	4889                	li	a7,2
ffffffffc020054e:	00000073          	ecall
ffffffffc0200552:	2501                	sext.w	a0,a0
    {
        c = sbi_console_getchar();
    }
    local_intr_restore(intr_flag);
    return c;
}
ffffffffc0200554:	8082                	ret
int cons_getc(void) {
ffffffffc0200556:	1101                	addi	sp,sp,-32
ffffffffc0200558:	ec06                	sd	ra,24(sp)
        intr_disable();
ffffffffc020055a:	3d6000ef          	jal	ra,ffffffffc0200930 <intr_disable>
ffffffffc020055e:	4501                	li	a0,0
ffffffffc0200560:	4581                	li	a1,0
ffffffffc0200562:	4601                	li	a2,0
ffffffffc0200564:	4889                	li	a7,2
ffffffffc0200566:	00000073          	ecall
ffffffffc020056a:	2501                	sext.w	a0,a0
ffffffffc020056c:	e42a                	sd	a0,8(sp)
        intr_enable();
ffffffffc020056e:	3bc000ef          	jal	ra,ffffffffc020092a <intr_enable>
}
ffffffffc0200572:	60e2                	ld	ra,24(sp)
ffffffffc0200574:	6522                	ld	a0,8(sp)
ffffffffc0200576:	6105                	addi	sp,sp,32
ffffffffc0200578:	8082                	ret

ffffffffc020057a <dtb_init>:

// 保存解析出的系统物理内存信息
static uint64_t memory_base = 0;
static uint64_t memory_size = 0;

void dtb_init(void) {
ffffffffc020057a:	7119                	addi	sp,sp,-128
    cprintf("DTB Init\n");
ffffffffc020057c:	00004517          	auipc	a0,0x4
ffffffffc0200580:	b7450513          	addi	a0,a0,-1164 # ffffffffc02040f0 <commands+0x88>
void dtb_init(void) {
ffffffffc0200584:	fc86                	sd	ra,120(sp)
ffffffffc0200586:	f8a2                	sd	s0,112(sp)
ffffffffc0200588:	e8d2                	sd	s4,80(sp)
ffffffffc020058a:	f4a6                	sd	s1,104(sp)
ffffffffc020058c:	f0ca                	sd	s2,96(sp)
ffffffffc020058e:	ecce                	sd	s3,88(sp)
ffffffffc0200590:	e4d6                	sd	s5,72(sp)
ffffffffc0200592:	e0da                	sd	s6,64(sp)
ffffffffc0200594:	fc5e                	sd	s7,56(sp)
ffffffffc0200596:	f862                	sd	s8,48(sp)
ffffffffc0200598:	f466                	sd	s9,40(sp)
ffffffffc020059a:	f06a                	sd	s10,32(sp)
ffffffffc020059c:	ec6e                	sd	s11,24(sp)
    cprintf("DTB Init\n");
ffffffffc020059e:	bf7ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("HartID: %ld\n", boot_hartid);
ffffffffc02005a2:	00009597          	auipc	a1,0x9
ffffffffc02005a6:	a5e5b583          	ld	a1,-1442(a1) # ffffffffc0209000 <boot_hartid>
ffffffffc02005aa:	00004517          	auipc	a0,0x4
ffffffffc02005ae:	b5650513          	addi	a0,a0,-1194 # ffffffffc0204100 <commands+0x98>
ffffffffc02005b2:	be3ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("DTB Address: 0x%lx\n", boot_dtb);
ffffffffc02005b6:	00009417          	auipc	s0,0x9
ffffffffc02005ba:	a5240413          	addi	s0,s0,-1454 # ffffffffc0209008 <boot_dtb>
ffffffffc02005be:	600c                	ld	a1,0(s0)
ffffffffc02005c0:	00004517          	auipc	a0,0x4
ffffffffc02005c4:	b5050513          	addi	a0,a0,-1200 # ffffffffc0204110 <commands+0xa8>
ffffffffc02005c8:	bcdff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    
    if (boot_dtb == 0) {
ffffffffc02005cc:	00043a03          	ld	s4,0(s0)
        cprintf("Error: DTB address is null\n");
ffffffffc02005d0:	00004517          	auipc	a0,0x4
ffffffffc02005d4:	b5850513          	addi	a0,a0,-1192 # ffffffffc0204128 <commands+0xc0>
    if (boot_dtb == 0) {
ffffffffc02005d8:	120a0463          	beqz	s4,ffffffffc0200700 <dtb_init+0x186>
        return;
    }
    
    // 转换为虚拟地址
    uintptr_t dtb_vaddr = boot_dtb + PHYSICAL_MEMORY_OFFSET;
ffffffffc02005dc:	57f5                	li	a5,-3
ffffffffc02005de:	07fa                	slli	a5,a5,0x1e
ffffffffc02005e0:	00fa0733          	add	a4,s4,a5
    const struct fdt_header *header = (const struct fdt_header *)dtb_vaddr;
    
    // 验证DTB
    uint32_t magic = fdt32_to_cpu(header->magic);
ffffffffc02005e4:	431c                	lw	a5,0(a4)
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02005e6:	00ff0637          	lui	a2,0xff0
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02005ea:	6b41                	lui	s6,0x10
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02005ec:	0087d59b          	srliw	a1,a5,0x8
ffffffffc02005f0:	0187969b          	slliw	a3,a5,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02005f4:	0187d51b          	srliw	a0,a5,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02005f8:	0105959b          	slliw	a1,a1,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02005fc:	0107d79b          	srliw	a5,a5,0x10
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200600:	8df1                	and	a1,a1,a2
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200602:	8ec9                	or	a3,a3,a0
ffffffffc0200604:	0087979b          	slliw	a5,a5,0x8
ffffffffc0200608:	1b7d                	addi	s6,s6,-1
ffffffffc020060a:	0167f7b3          	and	a5,a5,s6
ffffffffc020060e:	8dd5                	or	a1,a1,a3
ffffffffc0200610:	8ddd                	or	a1,a1,a5
    if (magic != 0xd00dfeed) {
ffffffffc0200612:	d00e07b7          	lui	a5,0xd00e0
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200616:	2581                	sext.w	a1,a1
    if (magic != 0xd00dfeed) {
ffffffffc0200618:	eed78793          	addi	a5,a5,-275 # ffffffffd00dfeed <end+0xfed2a01>
ffffffffc020061c:	10f59163          	bne	a1,a5,ffffffffc020071e <dtb_init+0x1a4>
        return;
    }
    
    // 提取内存信息
    uint64_t mem_base, mem_size;
    if (extract_memory_info(dtb_vaddr, header, &mem_base, &mem_size) == 0) {
ffffffffc0200620:	471c                	lw	a5,8(a4)
ffffffffc0200622:	4754                	lw	a3,12(a4)
    int in_memory_node = 0;
ffffffffc0200624:	4c81                	li	s9,0
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200626:	0087d59b          	srliw	a1,a5,0x8
ffffffffc020062a:	0086d51b          	srliw	a0,a3,0x8
ffffffffc020062e:	0186941b          	slliw	s0,a3,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200632:	0186d89b          	srliw	a7,a3,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200636:	01879a1b          	slliw	s4,a5,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc020063a:	0187d81b          	srliw	a6,a5,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020063e:	0105151b          	slliw	a0,a0,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200642:	0106d69b          	srliw	a3,a3,0x10
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200646:	0105959b          	slliw	a1,a1,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc020064a:	0107d79b          	srliw	a5,a5,0x10
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020064e:	8d71                	and	a0,a0,a2
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200650:	01146433          	or	s0,s0,a7
ffffffffc0200654:	0086969b          	slliw	a3,a3,0x8
ffffffffc0200658:	010a6a33          	or	s4,s4,a6
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020065c:	8e6d                	and	a2,a2,a1
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc020065e:	0087979b          	slliw	a5,a5,0x8
ffffffffc0200662:	8c49                	or	s0,s0,a0
ffffffffc0200664:	0166f6b3          	and	a3,a3,s6
ffffffffc0200668:	00ca6a33          	or	s4,s4,a2
ffffffffc020066c:	0167f7b3          	and	a5,a5,s6
ffffffffc0200670:	8c55                	or	s0,s0,a3
ffffffffc0200672:	00fa6a33          	or	s4,s4,a5
    const char *strings_base = (const char *)(dtb_vaddr + strings_offset);
ffffffffc0200676:	1402                	slli	s0,s0,0x20
    const uint32_t *struct_ptr = (const uint32_t *)(dtb_vaddr + struct_offset);
ffffffffc0200678:	1a02                	slli	s4,s4,0x20
    const char *strings_base = (const char *)(dtb_vaddr + strings_offset);
ffffffffc020067a:	9001                	srli	s0,s0,0x20
    const uint32_t *struct_ptr = (const uint32_t *)(dtb_vaddr + struct_offset);
ffffffffc020067c:	020a5a13          	srli	s4,s4,0x20
    const char *strings_base = (const char *)(dtb_vaddr + strings_offset);
ffffffffc0200680:	943a                	add	s0,s0,a4
    const uint32_t *struct_ptr = (const uint32_t *)(dtb_vaddr + struct_offset);
ffffffffc0200682:	9a3a                	add	s4,s4,a4
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200684:	00ff0c37          	lui	s8,0xff0
        switch (token) {
ffffffffc0200688:	4b8d                	li	s7,3
                if (in_memory_node && strcmp(prop_name, "reg") == 0 && prop_len >= 16) {
ffffffffc020068a:	00004917          	auipc	s2,0x4
ffffffffc020068e:	aee90913          	addi	s2,s2,-1298 # ffffffffc0204178 <commands+0x110>
ffffffffc0200692:	49bd                	li	s3,15
        switch (token) {
ffffffffc0200694:	4d91                	li	s11,4
ffffffffc0200696:	4d05                	li	s10,1
                if (strncmp(name, "memory", 6) == 0) {
ffffffffc0200698:	00004497          	auipc	s1,0x4
ffffffffc020069c:	ad848493          	addi	s1,s1,-1320 # ffffffffc0204170 <commands+0x108>
        uint32_t token = fdt32_to_cpu(*struct_ptr++);
ffffffffc02006a0:	000a2703          	lw	a4,0(s4)
ffffffffc02006a4:	004a0a93          	addi	s5,s4,4
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02006a8:	0087569b          	srliw	a3,a4,0x8
ffffffffc02006ac:	0187179b          	slliw	a5,a4,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02006b0:	0187561b          	srliw	a2,a4,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02006b4:	0106969b          	slliw	a3,a3,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02006b8:	0107571b          	srliw	a4,a4,0x10
ffffffffc02006bc:	8fd1                	or	a5,a5,a2
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02006be:	0186f6b3          	and	a3,a3,s8
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02006c2:	0087171b          	slliw	a4,a4,0x8
ffffffffc02006c6:	8fd5                	or	a5,a5,a3
ffffffffc02006c8:	00eb7733          	and	a4,s6,a4
ffffffffc02006cc:	8fd9                	or	a5,a5,a4
ffffffffc02006ce:	2781                	sext.w	a5,a5
        switch (token) {
ffffffffc02006d0:	09778c63          	beq	a5,s7,ffffffffc0200768 <dtb_init+0x1ee>
ffffffffc02006d4:	00fbea63          	bltu	s7,a5,ffffffffc02006e8 <dtb_init+0x16e>
ffffffffc02006d8:	07a78663          	beq	a5,s10,ffffffffc0200744 <dtb_init+0x1ca>
ffffffffc02006dc:	4709                	li	a4,2
ffffffffc02006de:	00e79763          	bne	a5,a4,ffffffffc02006ec <dtb_init+0x172>
ffffffffc02006e2:	4c81                	li	s9,0
ffffffffc02006e4:	8a56                	mv	s4,s5
ffffffffc02006e6:	bf6d                	j	ffffffffc02006a0 <dtb_init+0x126>
ffffffffc02006e8:	ffb78ee3          	beq	a5,s11,ffffffffc02006e4 <dtb_init+0x16a>
        cprintf("  End:  0x%016lx\n", mem_base + mem_size - 1);
        // 保存到全局变量，供 PMM 查询
        memory_base = mem_base;
        memory_size = mem_size;
    } else {
        cprintf("Warning: Could not extract memory info from DTB\n");
ffffffffc02006ec:	00004517          	auipc	a0,0x4
ffffffffc02006f0:	b0450513          	addi	a0,a0,-1276 # ffffffffc02041f0 <commands+0x188>
ffffffffc02006f4:	aa1ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    }
    cprintf("DTB init completed\n");
ffffffffc02006f8:	00004517          	auipc	a0,0x4
ffffffffc02006fc:	b3050513          	addi	a0,a0,-1232 # ffffffffc0204228 <commands+0x1c0>
}
ffffffffc0200700:	7446                	ld	s0,112(sp)
ffffffffc0200702:	70e6                	ld	ra,120(sp)
ffffffffc0200704:	74a6                	ld	s1,104(sp)
ffffffffc0200706:	7906                	ld	s2,96(sp)
ffffffffc0200708:	69e6                	ld	s3,88(sp)
ffffffffc020070a:	6a46                	ld	s4,80(sp)
ffffffffc020070c:	6aa6                	ld	s5,72(sp)
ffffffffc020070e:	6b06                	ld	s6,64(sp)
ffffffffc0200710:	7be2                	ld	s7,56(sp)
ffffffffc0200712:	7c42                	ld	s8,48(sp)
ffffffffc0200714:	7ca2                	ld	s9,40(sp)
ffffffffc0200716:	7d02                	ld	s10,32(sp)
ffffffffc0200718:	6de2                	ld	s11,24(sp)
ffffffffc020071a:	6109                	addi	sp,sp,128
    cprintf("DTB init completed\n");
ffffffffc020071c:	bca5                	j	ffffffffc0200194 <cprintf>
}
ffffffffc020071e:	7446                	ld	s0,112(sp)
ffffffffc0200720:	70e6                	ld	ra,120(sp)
ffffffffc0200722:	74a6                	ld	s1,104(sp)
ffffffffc0200724:	7906                	ld	s2,96(sp)
ffffffffc0200726:	69e6                	ld	s3,88(sp)
ffffffffc0200728:	6a46                	ld	s4,80(sp)
ffffffffc020072a:	6aa6                	ld	s5,72(sp)
ffffffffc020072c:	6b06                	ld	s6,64(sp)
ffffffffc020072e:	7be2                	ld	s7,56(sp)
ffffffffc0200730:	7c42                	ld	s8,48(sp)
ffffffffc0200732:	7ca2                	ld	s9,40(sp)
ffffffffc0200734:	7d02                	ld	s10,32(sp)
ffffffffc0200736:	6de2                	ld	s11,24(sp)
        cprintf("Error: Invalid DTB magic number: 0x%x\n", magic);
ffffffffc0200738:	00004517          	auipc	a0,0x4
ffffffffc020073c:	a1050513          	addi	a0,a0,-1520 # ffffffffc0204148 <commands+0xe0>
}
ffffffffc0200740:	6109                	addi	sp,sp,128
        cprintf("Error: Invalid DTB magic number: 0x%x\n", magic);
ffffffffc0200742:	bc89                	j	ffffffffc0200194 <cprintf>
                int name_len = strlen(name);
ffffffffc0200744:	8556                	mv	a0,s5
ffffffffc0200746:	5c4030ef          	jal	ra,ffffffffc0203d0a <strlen>
ffffffffc020074a:	8a2a                	mv	s4,a0
                if (strncmp(name, "memory", 6) == 0) {
ffffffffc020074c:	4619                	li	a2,6
ffffffffc020074e:	85a6                	mv	a1,s1
ffffffffc0200750:	8556                	mv	a0,s5
                int name_len = strlen(name);
ffffffffc0200752:	2a01                	sext.w	s4,s4
                if (strncmp(name, "memory", 6) == 0) {
ffffffffc0200754:	61c030ef          	jal	ra,ffffffffc0203d70 <strncmp>
ffffffffc0200758:	e111                	bnez	a0,ffffffffc020075c <dtb_init+0x1e2>
                    in_memory_node = 1;
ffffffffc020075a:	4c85                	li	s9,1
                struct_ptr = (const uint32_t *)(((uintptr_t)struct_ptr + name_len + 4) & ~3);
ffffffffc020075c:	0a91                	addi	s5,s5,4
ffffffffc020075e:	9ad2                	add	s5,s5,s4
ffffffffc0200760:	ffcafa93          	andi	s5,s5,-4
        switch (token) {
ffffffffc0200764:	8a56                	mv	s4,s5
ffffffffc0200766:	bf2d                	j	ffffffffc02006a0 <dtb_init+0x126>
                uint32_t prop_len = fdt32_to_cpu(*struct_ptr++);
ffffffffc0200768:	004a2783          	lw	a5,4(s4)
                uint32_t prop_nameoff = fdt32_to_cpu(*struct_ptr++);
ffffffffc020076c:	00ca0693          	addi	a3,s4,12
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200770:	0087d71b          	srliw	a4,a5,0x8
ffffffffc0200774:	01879a9b          	slliw	s5,a5,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200778:	0187d61b          	srliw	a2,a5,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020077c:	0107171b          	slliw	a4,a4,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200780:	0107d79b          	srliw	a5,a5,0x10
ffffffffc0200784:	00caeab3          	or	s5,s5,a2
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200788:	01877733          	and	a4,a4,s8
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc020078c:	0087979b          	slliw	a5,a5,0x8
ffffffffc0200790:	00eaeab3          	or	s5,s5,a4
ffffffffc0200794:	00fb77b3          	and	a5,s6,a5
ffffffffc0200798:	00faeab3          	or	s5,s5,a5
ffffffffc020079c:	2a81                	sext.w	s5,s5
                if (in_memory_node && strcmp(prop_name, "reg") == 0 && prop_len >= 16) {
ffffffffc020079e:	000c9c63          	bnez	s9,ffffffffc02007b6 <dtb_init+0x23c>
                struct_ptr = (const uint32_t *)(((uintptr_t)struct_ptr + prop_len + 3) & ~3);
ffffffffc02007a2:	1a82                	slli	s5,s5,0x20
ffffffffc02007a4:	00368793          	addi	a5,a3,3
ffffffffc02007a8:	020ada93          	srli	s5,s5,0x20
ffffffffc02007ac:	9abe                	add	s5,s5,a5
ffffffffc02007ae:	ffcafa93          	andi	s5,s5,-4
        switch (token) {
ffffffffc02007b2:	8a56                	mv	s4,s5
ffffffffc02007b4:	b5f5                	j	ffffffffc02006a0 <dtb_init+0x126>
                uint32_t prop_nameoff = fdt32_to_cpu(*struct_ptr++);
ffffffffc02007b6:	008a2783          	lw	a5,8(s4)
                if (in_memory_node && strcmp(prop_name, "reg") == 0 && prop_len >= 16) {
ffffffffc02007ba:	85ca                	mv	a1,s2
ffffffffc02007bc:	e436                	sd	a3,8(sp)
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02007be:	0087d51b          	srliw	a0,a5,0x8
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02007c2:	0187d61b          	srliw	a2,a5,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02007c6:	0187971b          	slliw	a4,a5,0x18
ffffffffc02007ca:	0105151b          	slliw	a0,a0,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02007ce:	0107d79b          	srliw	a5,a5,0x10
ffffffffc02007d2:	8f51                	or	a4,a4,a2
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02007d4:	01857533          	and	a0,a0,s8
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02007d8:	0087979b          	slliw	a5,a5,0x8
ffffffffc02007dc:	8d59                	or	a0,a0,a4
ffffffffc02007de:	00fb77b3          	and	a5,s6,a5
ffffffffc02007e2:	8d5d                	or	a0,a0,a5
                const char *prop_name = strings_base + prop_nameoff;
ffffffffc02007e4:	1502                	slli	a0,a0,0x20
ffffffffc02007e6:	9101                	srli	a0,a0,0x20
                if (in_memory_node && strcmp(prop_name, "reg") == 0 && prop_len >= 16) {
ffffffffc02007e8:	9522                	add	a0,a0,s0
ffffffffc02007ea:	568030ef          	jal	ra,ffffffffc0203d52 <strcmp>
ffffffffc02007ee:	66a2                	ld	a3,8(sp)
ffffffffc02007f0:	f94d                	bnez	a0,ffffffffc02007a2 <dtb_init+0x228>
ffffffffc02007f2:	fb59f8e3          	bgeu	s3,s5,ffffffffc02007a2 <dtb_init+0x228>
                    *mem_base = fdt64_to_cpu(reg_data[0]);
ffffffffc02007f6:	00ca3783          	ld	a5,12(s4)
                    *mem_size = fdt64_to_cpu(reg_data[1]);
ffffffffc02007fa:	014a3703          	ld	a4,20(s4)
        cprintf("Physical Memory from DTB:\n");
ffffffffc02007fe:	00004517          	auipc	a0,0x4
ffffffffc0200802:	98250513          	addi	a0,a0,-1662 # ffffffffc0204180 <commands+0x118>
           fdt32_to_cpu(x >> 32);
ffffffffc0200806:	4207d613          	srai	a2,a5,0x20
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020080a:	0087d31b          	srliw	t1,a5,0x8
           fdt32_to_cpu(x >> 32);
ffffffffc020080e:	42075593          	srai	a1,a4,0x20
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200812:	0187de1b          	srliw	t3,a5,0x18
ffffffffc0200816:	0186581b          	srliw	a6,a2,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020081a:	0187941b          	slliw	s0,a5,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc020081e:	0107d89b          	srliw	a7,a5,0x10
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200822:	0187d693          	srli	a3,a5,0x18
ffffffffc0200826:	01861f1b          	slliw	t5,a2,0x18
ffffffffc020082a:	0087579b          	srliw	a5,a4,0x8
ffffffffc020082e:	0103131b          	slliw	t1,t1,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200832:	0106561b          	srliw	a2,a2,0x10
ffffffffc0200836:	010f6f33          	or	t5,t5,a6
ffffffffc020083a:	0187529b          	srliw	t0,a4,0x18
ffffffffc020083e:	0185df9b          	srliw	t6,a1,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200842:	01837333          	and	t1,t1,s8
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200846:	01c46433          	or	s0,s0,t3
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020084a:	0186f6b3          	and	a3,a3,s8
ffffffffc020084e:	01859e1b          	slliw	t3,a1,0x18
ffffffffc0200852:	01871e9b          	slliw	t4,a4,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200856:	0107581b          	srliw	a6,a4,0x10
ffffffffc020085a:	0086161b          	slliw	a2,a2,0x8
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020085e:	8361                	srli	a4,a4,0x18
ffffffffc0200860:	0107979b          	slliw	a5,a5,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200864:	0105d59b          	srliw	a1,a1,0x10
ffffffffc0200868:	01e6e6b3          	or	a3,a3,t5
ffffffffc020086c:	00cb7633          	and	a2,s6,a2
ffffffffc0200870:	0088181b          	slliw	a6,a6,0x8
ffffffffc0200874:	0085959b          	slliw	a1,a1,0x8
ffffffffc0200878:	00646433          	or	s0,s0,t1
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020087c:	0187f7b3          	and	a5,a5,s8
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200880:	01fe6333          	or	t1,t3,t6
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200884:	01877c33          	and	s8,a4,s8
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200888:	0088989b          	slliw	a7,a7,0x8
ffffffffc020088c:	011b78b3          	and	a7,s6,a7
ffffffffc0200890:	005eeeb3          	or	t4,t4,t0
ffffffffc0200894:	00c6e733          	or	a4,a3,a2
ffffffffc0200898:	006c6c33          	or	s8,s8,t1
ffffffffc020089c:	010b76b3          	and	a3,s6,a6
ffffffffc02008a0:	00bb7b33          	and	s6,s6,a1
ffffffffc02008a4:	01d7e7b3          	or	a5,a5,t4
ffffffffc02008a8:	016c6b33          	or	s6,s8,s6
ffffffffc02008ac:	01146433          	or	s0,s0,a7
ffffffffc02008b0:	8fd5                	or	a5,a5,a3
           fdt32_to_cpu(x >> 32);
ffffffffc02008b2:	1702                	slli	a4,a4,0x20
ffffffffc02008b4:	1b02                	slli	s6,s6,0x20
    return ((uint64_t)fdt32_to_cpu(x & 0xffffffff) << 32) | 
ffffffffc02008b6:	1782                	slli	a5,a5,0x20
           fdt32_to_cpu(x >> 32);
ffffffffc02008b8:	9301                	srli	a4,a4,0x20
    return ((uint64_t)fdt32_to_cpu(x & 0xffffffff) << 32) | 
ffffffffc02008ba:	1402                	slli	s0,s0,0x20
           fdt32_to_cpu(x >> 32);
ffffffffc02008bc:	020b5b13          	srli	s6,s6,0x20
    return ((uint64_t)fdt32_to_cpu(x & 0xffffffff) << 32) | 
ffffffffc02008c0:	0167eb33          	or	s6,a5,s6
ffffffffc02008c4:	8c59                	or	s0,s0,a4
        cprintf("Physical Memory from DTB:\n");
ffffffffc02008c6:	8cfff0ef          	jal	ra,ffffffffc0200194 <cprintf>
        cprintf("  Base: 0x%016lx\n", mem_base);
ffffffffc02008ca:	85a2                	mv	a1,s0
ffffffffc02008cc:	00004517          	auipc	a0,0x4
ffffffffc02008d0:	8d450513          	addi	a0,a0,-1836 # ffffffffc02041a0 <commands+0x138>
ffffffffc02008d4:	8c1ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
        cprintf("  Size: 0x%016lx (%ld MB)\n", mem_size, mem_size / (1024 * 1024));
ffffffffc02008d8:	014b5613          	srli	a2,s6,0x14
ffffffffc02008dc:	85da                	mv	a1,s6
ffffffffc02008de:	00004517          	auipc	a0,0x4
ffffffffc02008e2:	8da50513          	addi	a0,a0,-1830 # ffffffffc02041b8 <commands+0x150>
ffffffffc02008e6:	8afff0ef          	jal	ra,ffffffffc0200194 <cprintf>
        cprintf("  End:  0x%016lx\n", mem_base + mem_size - 1);
ffffffffc02008ea:	008b05b3          	add	a1,s6,s0
ffffffffc02008ee:	15fd                	addi	a1,a1,-1
ffffffffc02008f0:	00004517          	auipc	a0,0x4
ffffffffc02008f4:	8e850513          	addi	a0,a0,-1816 # ffffffffc02041d8 <commands+0x170>
ffffffffc02008f8:	89dff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("DTB init completed\n");
ffffffffc02008fc:	00004517          	auipc	a0,0x4
ffffffffc0200900:	92c50513          	addi	a0,a0,-1748 # ffffffffc0204228 <commands+0x1c0>
        memory_base = mem_base;
ffffffffc0200904:	0000d797          	auipc	a5,0xd
ffffffffc0200908:	b687be23          	sd	s0,-1156(a5) # ffffffffc020d480 <memory_base>
        memory_size = mem_size;
ffffffffc020090c:	0000d797          	auipc	a5,0xd
ffffffffc0200910:	b767be23          	sd	s6,-1156(a5) # ffffffffc020d488 <memory_size>
    cprintf("DTB init completed\n");
ffffffffc0200914:	b3f5                	j	ffffffffc0200700 <dtb_init+0x186>

ffffffffc0200916 <get_memory_base>:

uint64_t get_memory_base(void) {
    return memory_base;
}
ffffffffc0200916:	0000d517          	auipc	a0,0xd
ffffffffc020091a:	b6a53503          	ld	a0,-1174(a0) # ffffffffc020d480 <memory_base>
ffffffffc020091e:	8082                	ret

ffffffffc0200920 <get_memory_size>:

uint64_t get_memory_size(void) {
    return memory_size;
ffffffffc0200920:	0000d517          	auipc	a0,0xd
ffffffffc0200924:	b6853503          	ld	a0,-1176(a0) # ffffffffc020d488 <memory_size>
ffffffffc0200928:	8082                	ret

ffffffffc020092a <intr_enable>:
#include <intr.h>
#include <riscv.h>

/* intr_enable - enable irq interrupt */
void intr_enable(void) { set_csr(sstatus, SSTATUS_SIE); }
ffffffffc020092a:	100167f3          	csrrsi	a5,sstatus,2
ffffffffc020092e:	8082                	ret

ffffffffc0200930 <intr_disable>:

/* intr_disable - disable irq interrupt */
void intr_disable(void) { clear_csr(sstatus, SSTATUS_SIE); }
ffffffffc0200930:	100177f3          	csrrci	a5,sstatus,2
ffffffffc0200934:	8082                	ret

ffffffffc0200936 <pic_init>:
#include <picirq.h>

void pic_enable(unsigned int irq) {}

/* pic_init - initialize the 8259A interrupt controllers */
void pic_init(void) {}
ffffffffc0200936:	8082                	ret

ffffffffc0200938 <idt_init>:
void idt_init(void)
{
    extern void __alltraps(void);
    /* Set sscratch register to 0, indicating to exception vector that we are
     * presently executing in the kernel */
    write_csr(sscratch, 0);
ffffffffc0200938:	14005073          	csrwi	sscratch,0
    /* Set the exception vector address */
    write_csr(stvec, &__alltraps);
ffffffffc020093c:	00000797          	auipc	a5,0x0
ffffffffc0200940:	3e478793          	addi	a5,a5,996 # ffffffffc0200d20 <__alltraps>
ffffffffc0200944:	10579073          	csrw	stvec,a5
    /* Allow kernel to access user memory */
    set_csr(sstatus, SSTATUS_SUM);
ffffffffc0200948:	000407b7          	lui	a5,0x40
ffffffffc020094c:	1007a7f3          	csrrs	a5,sstatus,a5
}
ffffffffc0200950:	8082                	ret

ffffffffc0200952 <print_regs>:
    cprintf("  cause    0x%08x\n", tf->cause);
}

void print_regs(struct pushregs *gpr)
{
    cprintf("  zero     0x%08x\n", gpr->zero);
ffffffffc0200952:	610c                	ld	a1,0(a0)
{
ffffffffc0200954:	1141                	addi	sp,sp,-16
ffffffffc0200956:	e022                	sd	s0,0(sp)
ffffffffc0200958:	842a                	mv	s0,a0
    cprintf("  zero     0x%08x\n", gpr->zero);
ffffffffc020095a:	00004517          	auipc	a0,0x4
ffffffffc020095e:	8e650513          	addi	a0,a0,-1818 # ffffffffc0204240 <commands+0x1d8>
{
ffffffffc0200962:	e406                	sd	ra,8(sp)
    cprintf("  zero     0x%08x\n", gpr->zero);
ffffffffc0200964:	831ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  ra       0x%08x\n", gpr->ra);
ffffffffc0200968:	640c                	ld	a1,8(s0)
ffffffffc020096a:	00004517          	auipc	a0,0x4
ffffffffc020096e:	8ee50513          	addi	a0,a0,-1810 # ffffffffc0204258 <commands+0x1f0>
ffffffffc0200972:	823ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  sp       0x%08x\n", gpr->sp);
ffffffffc0200976:	680c                	ld	a1,16(s0)
ffffffffc0200978:	00004517          	auipc	a0,0x4
ffffffffc020097c:	8f850513          	addi	a0,a0,-1800 # ffffffffc0204270 <commands+0x208>
ffffffffc0200980:	815ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  gp       0x%08x\n", gpr->gp);
ffffffffc0200984:	6c0c                	ld	a1,24(s0)
ffffffffc0200986:	00004517          	auipc	a0,0x4
ffffffffc020098a:	90250513          	addi	a0,a0,-1790 # ffffffffc0204288 <commands+0x220>
ffffffffc020098e:	807ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  tp       0x%08x\n", gpr->tp);
ffffffffc0200992:	700c                	ld	a1,32(s0)
ffffffffc0200994:	00004517          	auipc	a0,0x4
ffffffffc0200998:	90c50513          	addi	a0,a0,-1780 # ffffffffc02042a0 <commands+0x238>
ffffffffc020099c:	ff8ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  t0       0x%08x\n", gpr->t0);
ffffffffc02009a0:	740c                	ld	a1,40(s0)
ffffffffc02009a2:	00004517          	auipc	a0,0x4
ffffffffc02009a6:	91650513          	addi	a0,a0,-1770 # ffffffffc02042b8 <commands+0x250>
ffffffffc02009aa:	feaff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  t1       0x%08x\n", gpr->t1);
ffffffffc02009ae:	780c                	ld	a1,48(s0)
ffffffffc02009b0:	00004517          	auipc	a0,0x4
ffffffffc02009b4:	92050513          	addi	a0,a0,-1760 # ffffffffc02042d0 <commands+0x268>
ffffffffc02009b8:	fdcff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  t2       0x%08x\n", gpr->t2);
ffffffffc02009bc:	7c0c                	ld	a1,56(s0)
ffffffffc02009be:	00004517          	auipc	a0,0x4
ffffffffc02009c2:	92a50513          	addi	a0,a0,-1750 # ffffffffc02042e8 <commands+0x280>
ffffffffc02009c6:	fceff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s0       0x%08x\n", gpr->s0);
ffffffffc02009ca:	602c                	ld	a1,64(s0)
ffffffffc02009cc:	00004517          	auipc	a0,0x4
ffffffffc02009d0:	93450513          	addi	a0,a0,-1740 # ffffffffc0204300 <commands+0x298>
ffffffffc02009d4:	fc0ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s1       0x%08x\n", gpr->s1);
ffffffffc02009d8:	642c                	ld	a1,72(s0)
ffffffffc02009da:	00004517          	auipc	a0,0x4
ffffffffc02009de:	93e50513          	addi	a0,a0,-1730 # ffffffffc0204318 <commands+0x2b0>
ffffffffc02009e2:	fb2ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  a0       0x%08x\n", gpr->a0);
ffffffffc02009e6:	682c                	ld	a1,80(s0)
ffffffffc02009e8:	00004517          	auipc	a0,0x4
ffffffffc02009ec:	94850513          	addi	a0,a0,-1720 # ffffffffc0204330 <commands+0x2c8>
ffffffffc02009f0:	fa4ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  a1       0x%08x\n", gpr->a1);
ffffffffc02009f4:	6c2c                	ld	a1,88(s0)
ffffffffc02009f6:	00004517          	auipc	a0,0x4
ffffffffc02009fa:	95250513          	addi	a0,a0,-1710 # ffffffffc0204348 <commands+0x2e0>
ffffffffc02009fe:	f96ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  a2       0x%08x\n", gpr->a2);
ffffffffc0200a02:	702c                	ld	a1,96(s0)
ffffffffc0200a04:	00004517          	auipc	a0,0x4
ffffffffc0200a08:	95c50513          	addi	a0,a0,-1700 # ffffffffc0204360 <commands+0x2f8>
ffffffffc0200a0c:	f88ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  a3       0x%08x\n", gpr->a3);
ffffffffc0200a10:	742c                	ld	a1,104(s0)
ffffffffc0200a12:	00004517          	auipc	a0,0x4
ffffffffc0200a16:	96650513          	addi	a0,a0,-1690 # ffffffffc0204378 <commands+0x310>
ffffffffc0200a1a:	f7aff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  a4       0x%08x\n", gpr->a4);
ffffffffc0200a1e:	782c                	ld	a1,112(s0)
ffffffffc0200a20:	00004517          	auipc	a0,0x4
ffffffffc0200a24:	97050513          	addi	a0,a0,-1680 # ffffffffc0204390 <commands+0x328>
ffffffffc0200a28:	f6cff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  a5       0x%08x\n", gpr->a5);
ffffffffc0200a2c:	7c2c                	ld	a1,120(s0)
ffffffffc0200a2e:	00004517          	auipc	a0,0x4
ffffffffc0200a32:	97a50513          	addi	a0,a0,-1670 # ffffffffc02043a8 <commands+0x340>
ffffffffc0200a36:	f5eff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  a6       0x%08x\n", gpr->a6);
ffffffffc0200a3a:	604c                	ld	a1,128(s0)
ffffffffc0200a3c:	00004517          	auipc	a0,0x4
ffffffffc0200a40:	98450513          	addi	a0,a0,-1660 # ffffffffc02043c0 <commands+0x358>
ffffffffc0200a44:	f50ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  a7       0x%08x\n", gpr->a7);
ffffffffc0200a48:	644c                	ld	a1,136(s0)
ffffffffc0200a4a:	00004517          	auipc	a0,0x4
ffffffffc0200a4e:	98e50513          	addi	a0,a0,-1650 # ffffffffc02043d8 <commands+0x370>
ffffffffc0200a52:	f42ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s2       0x%08x\n", gpr->s2);
ffffffffc0200a56:	684c                	ld	a1,144(s0)
ffffffffc0200a58:	00004517          	auipc	a0,0x4
ffffffffc0200a5c:	99850513          	addi	a0,a0,-1640 # ffffffffc02043f0 <commands+0x388>
ffffffffc0200a60:	f34ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s3       0x%08x\n", gpr->s3);
ffffffffc0200a64:	6c4c                	ld	a1,152(s0)
ffffffffc0200a66:	00004517          	auipc	a0,0x4
ffffffffc0200a6a:	9a250513          	addi	a0,a0,-1630 # ffffffffc0204408 <commands+0x3a0>
ffffffffc0200a6e:	f26ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s4       0x%08x\n", gpr->s4);
ffffffffc0200a72:	704c                	ld	a1,160(s0)
ffffffffc0200a74:	00004517          	auipc	a0,0x4
ffffffffc0200a78:	9ac50513          	addi	a0,a0,-1620 # ffffffffc0204420 <commands+0x3b8>
ffffffffc0200a7c:	f18ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s5       0x%08x\n", gpr->s5);
ffffffffc0200a80:	744c                	ld	a1,168(s0)
ffffffffc0200a82:	00004517          	auipc	a0,0x4
ffffffffc0200a86:	9b650513          	addi	a0,a0,-1610 # ffffffffc0204438 <commands+0x3d0>
ffffffffc0200a8a:	f0aff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s6       0x%08x\n", gpr->s6);
ffffffffc0200a8e:	784c                	ld	a1,176(s0)
ffffffffc0200a90:	00004517          	auipc	a0,0x4
ffffffffc0200a94:	9c050513          	addi	a0,a0,-1600 # ffffffffc0204450 <commands+0x3e8>
ffffffffc0200a98:	efcff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s7       0x%08x\n", gpr->s7);
ffffffffc0200a9c:	7c4c                	ld	a1,184(s0)
ffffffffc0200a9e:	00004517          	auipc	a0,0x4
ffffffffc0200aa2:	9ca50513          	addi	a0,a0,-1590 # ffffffffc0204468 <commands+0x400>
ffffffffc0200aa6:	eeeff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s8       0x%08x\n", gpr->s8);
ffffffffc0200aaa:	606c                	ld	a1,192(s0)
ffffffffc0200aac:	00004517          	auipc	a0,0x4
ffffffffc0200ab0:	9d450513          	addi	a0,a0,-1580 # ffffffffc0204480 <commands+0x418>
ffffffffc0200ab4:	ee0ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s9       0x%08x\n", gpr->s9);
ffffffffc0200ab8:	646c                	ld	a1,200(s0)
ffffffffc0200aba:	00004517          	auipc	a0,0x4
ffffffffc0200abe:	9de50513          	addi	a0,a0,-1570 # ffffffffc0204498 <commands+0x430>
ffffffffc0200ac2:	ed2ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s10      0x%08x\n", gpr->s10);
ffffffffc0200ac6:	686c                	ld	a1,208(s0)
ffffffffc0200ac8:	00004517          	auipc	a0,0x4
ffffffffc0200acc:	9e850513          	addi	a0,a0,-1560 # ffffffffc02044b0 <commands+0x448>
ffffffffc0200ad0:	ec4ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  s11      0x%08x\n", gpr->s11);
ffffffffc0200ad4:	6c6c                	ld	a1,216(s0)
ffffffffc0200ad6:	00004517          	auipc	a0,0x4
ffffffffc0200ada:	9f250513          	addi	a0,a0,-1550 # ffffffffc02044c8 <commands+0x460>
ffffffffc0200ade:	eb6ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  t3       0x%08x\n", gpr->t3);
ffffffffc0200ae2:	706c                	ld	a1,224(s0)
ffffffffc0200ae4:	00004517          	auipc	a0,0x4
ffffffffc0200ae8:	9fc50513          	addi	a0,a0,-1540 # ffffffffc02044e0 <commands+0x478>
ffffffffc0200aec:	ea8ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  t4       0x%08x\n", gpr->t4);
ffffffffc0200af0:	746c                	ld	a1,232(s0)
ffffffffc0200af2:	00004517          	auipc	a0,0x4
ffffffffc0200af6:	a0650513          	addi	a0,a0,-1530 # ffffffffc02044f8 <commands+0x490>
ffffffffc0200afa:	e9aff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  t5       0x%08x\n", gpr->t5);
ffffffffc0200afe:	786c                	ld	a1,240(s0)
ffffffffc0200b00:	00004517          	auipc	a0,0x4
ffffffffc0200b04:	a1050513          	addi	a0,a0,-1520 # ffffffffc0204510 <commands+0x4a8>
ffffffffc0200b08:	e8cff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  t6       0x%08x\n", gpr->t6);
ffffffffc0200b0c:	7c6c                	ld	a1,248(s0)
}
ffffffffc0200b0e:	6402                	ld	s0,0(sp)
ffffffffc0200b10:	60a2                	ld	ra,8(sp)
    cprintf("  t6       0x%08x\n", gpr->t6);
ffffffffc0200b12:	00004517          	auipc	a0,0x4
ffffffffc0200b16:	a1650513          	addi	a0,a0,-1514 # ffffffffc0204528 <commands+0x4c0>
}
ffffffffc0200b1a:	0141                	addi	sp,sp,16
    cprintf("  t6       0x%08x\n", gpr->t6);
ffffffffc0200b1c:	e78ff06f          	j	ffffffffc0200194 <cprintf>

ffffffffc0200b20 <print_trapframe>:
{
ffffffffc0200b20:	1141                	addi	sp,sp,-16
ffffffffc0200b22:	e022                	sd	s0,0(sp)
    cprintf("trapframe at %p\n", tf);
ffffffffc0200b24:	85aa                	mv	a1,a0
{
ffffffffc0200b26:	842a                	mv	s0,a0
    cprintf("trapframe at %p\n", tf);
ffffffffc0200b28:	00004517          	auipc	a0,0x4
ffffffffc0200b2c:	a1850513          	addi	a0,a0,-1512 # ffffffffc0204540 <commands+0x4d8>
{
ffffffffc0200b30:	e406                	sd	ra,8(sp)
    cprintf("trapframe at %p\n", tf);
ffffffffc0200b32:	e62ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    print_regs(&tf->gpr);
ffffffffc0200b36:	8522                	mv	a0,s0
ffffffffc0200b38:	e1bff0ef          	jal	ra,ffffffffc0200952 <print_regs>
    cprintf("  status   0x%08x\n", tf->status);
ffffffffc0200b3c:	10043583          	ld	a1,256(s0)
ffffffffc0200b40:	00004517          	auipc	a0,0x4
ffffffffc0200b44:	a1850513          	addi	a0,a0,-1512 # ffffffffc0204558 <commands+0x4f0>
ffffffffc0200b48:	e4cff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  epc      0x%08x\n", tf->epc);
ffffffffc0200b4c:	10843583          	ld	a1,264(s0)
ffffffffc0200b50:	00004517          	auipc	a0,0x4
ffffffffc0200b54:	a2050513          	addi	a0,a0,-1504 # ffffffffc0204570 <commands+0x508>
ffffffffc0200b58:	e3cff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  badvaddr 0x%08x\n", tf->badvaddr);
ffffffffc0200b5c:	11043583          	ld	a1,272(s0)
ffffffffc0200b60:	00004517          	auipc	a0,0x4
ffffffffc0200b64:	a2850513          	addi	a0,a0,-1496 # ffffffffc0204588 <commands+0x520>
ffffffffc0200b68:	e2cff0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("  cause    0x%08x\n", tf->cause);
ffffffffc0200b6c:	11843583          	ld	a1,280(s0)
}
ffffffffc0200b70:	6402                	ld	s0,0(sp)
ffffffffc0200b72:	60a2                	ld	ra,8(sp)
    cprintf("  cause    0x%08x\n", tf->cause);
ffffffffc0200b74:	00004517          	auipc	a0,0x4
ffffffffc0200b78:	a2c50513          	addi	a0,a0,-1492 # ffffffffc02045a0 <commands+0x538>
}
ffffffffc0200b7c:	0141                	addi	sp,sp,16
    cprintf("  cause    0x%08x\n", tf->cause);
ffffffffc0200b7e:	e16ff06f          	j	ffffffffc0200194 <cprintf>

ffffffffc0200b82 <interrupt_handler>:

extern struct mm_struct *check_mm_struct;

void interrupt_handler(struct trapframe *tf)
{
    intptr_t cause = (tf->cause << 1) >> 1;
ffffffffc0200b82:	11853783          	ld	a5,280(a0)
ffffffffc0200b86:	472d                	li	a4,11
ffffffffc0200b88:	0786                	slli	a5,a5,0x1
ffffffffc0200b8a:	8385                	srli	a5,a5,0x1
ffffffffc0200b8c:	08f76963          	bltu	a4,a5,ffffffffc0200c1e <interrupt_handler+0x9c>
ffffffffc0200b90:	00004717          	auipc	a4,0x4
ffffffffc0200b94:	ad870713          	addi	a4,a4,-1320 # ffffffffc0204668 <commands+0x600>
ffffffffc0200b98:	078a                	slli	a5,a5,0x2
ffffffffc0200b9a:	97ba                	add	a5,a5,a4
ffffffffc0200b9c:	439c                	lw	a5,0(a5)
ffffffffc0200b9e:	97ba                	add	a5,a5,a4
ffffffffc0200ba0:	8782                	jr	a5
        break;
    case IRQ_H_SOFT:
        cprintf("Hypervisor software interrupt\n");
        break;
    case IRQ_M_SOFT:
        cprintf("Machine software interrupt\n");
ffffffffc0200ba2:	00004517          	auipc	a0,0x4
ffffffffc0200ba6:	a7650513          	addi	a0,a0,-1418 # ffffffffc0204618 <commands+0x5b0>
ffffffffc0200baa:	deaff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Hypervisor software interrupt\n");
ffffffffc0200bae:	00004517          	auipc	a0,0x4
ffffffffc0200bb2:	a4a50513          	addi	a0,a0,-1462 # ffffffffc02045f8 <commands+0x590>
ffffffffc0200bb6:	ddeff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("User software interrupt\n");
ffffffffc0200bba:	00004517          	auipc	a0,0x4
ffffffffc0200bbe:	9fe50513          	addi	a0,a0,-1538 # ffffffffc02045b8 <commands+0x550>
ffffffffc0200bc2:	dd2ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Supervisor software interrupt\n");
ffffffffc0200bc6:	00004517          	auipc	a0,0x4
ffffffffc0200bca:	a1250513          	addi	a0,a0,-1518 # ffffffffc02045d8 <commands+0x570>
ffffffffc0200bce:	dc6ff06f          	j	ffffffffc0200194 <cprintf>
{
ffffffffc0200bd2:	1141                	addi	sp,sp,-16
ffffffffc0200bd4:	e406                	sd	ra,8(sp)
        // In fact, Call sbi_set_timer will clear STIP, or you can clear it
        // directly.
        // clear_csr(sip, SIP_STIP);

        /*LAB3 请补充你在lab3中的代码 */
        clock_set_next_event();
ffffffffc0200bd6:	919ff0ef          	jal	ra,ffffffffc02004ee <clock_set_next_event>
        if (++ticks % TICK_NUM == 0) {
ffffffffc0200bda:	0000d697          	auipc	a3,0xd
ffffffffc0200bde:	89668693          	addi	a3,a3,-1898 # ffffffffc020d470 <ticks>
ffffffffc0200be2:	629c                	ld	a5,0(a3)
ffffffffc0200be4:	06400713          	li	a4,100
ffffffffc0200be8:	0785                	addi	a5,a5,1
ffffffffc0200bea:	02e7f733          	remu	a4,a5,a4
ffffffffc0200bee:	e29c                	sd	a5,0(a3)
ffffffffc0200bf0:	cb05                	beqz	a4,ffffffffc0200c20 <interrupt_handler+0x9e>
            print_ticks();
            num++;
        }
        if (num == NUM){
ffffffffc0200bf2:	0000d797          	auipc	a5,0xd
ffffffffc0200bf6:	89e7b783          	ld	a5,-1890(a5) # ffffffffc020d490 <num>
ffffffffc0200bfa:	4729                	li	a4,10
ffffffffc0200bfc:	00e79863          	bne	a5,a4,ffffffffc0200c0c <interrupt_handler+0x8a>
	SBI_CALL_0(SBI_SHUTDOWN);
ffffffffc0200c00:	4501                	li	a0,0
ffffffffc0200c02:	4581                	li	a1,0
ffffffffc0200c04:	4601                	li	a2,0
ffffffffc0200c06:	48a1                	li	a7,8
ffffffffc0200c08:	00000073          	ecall
        break;
    default:
        print_trapframe(tf);
        break;
    }
}
ffffffffc0200c0c:	60a2                	ld	ra,8(sp)
ffffffffc0200c0e:	0141                	addi	sp,sp,16
ffffffffc0200c10:	8082                	ret
        cprintf("Supervisor external interrupt\n");
ffffffffc0200c12:	00004517          	auipc	a0,0x4
ffffffffc0200c16:	a3650513          	addi	a0,a0,-1482 # ffffffffc0204648 <commands+0x5e0>
ffffffffc0200c1a:	d7aff06f          	j	ffffffffc0200194 <cprintf>
        print_trapframe(tf);
ffffffffc0200c1e:	b709                	j	ffffffffc0200b20 <print_trapframe>
    cprintf("%d ticks\n", TICK_NUM);
ffffffffc0200c20:	06400593          	li	a1,100
ffffffffc0200c24:	00004517          	auipc	a0,0x4
ffffffffc0200c28:	a1450513          	addi	a0,a0,-1516 # ffffffffc0204638 <commands+0x5d0>
ffffffffc0200c2c:	d68ff0ef          	jal	ra,ffffffffc0200194 <cprintf>
            num++;
ffffffffc0200c30:	0000d717          	auipc	a4,0xd
ffffffffc0200c34:	86070713          	addi	a4,a4,-1952 # ffffffffc020d490 <num>
ffffffffc0200c38:	631c                	ld	a5,0(a4)
ffffffffc0200c3a:	0785                	addi	a5,a5,1
ffffffffc0200c3c:	e31c                	sd	a5,0(a4)
ffffffffc0200c3e:	bf75                	j	ffffffffc0200bfa <interrupt_handler+0x78>

ffffffffc0200c40 <exception_handler>:

void exception_handler(struct trapframe *tf)
{
    int ret;
    switch (tf->cause)
ffffffffc0200c40:	11853783          	ld	a5,280(a0)
ffffffffc0200c44:	473d                	li	a4,15
ffffffffc0200c46:	0cf76563          	bltu	a4,a5,ffffffffc0200d10 <exception_handler+0xd0>
ffffffffc0200c4a:	00004717          	auipc	a4,0x4
ffffffffc0200c4e:	be670713          	addi	a4,a4,-1050 # ffffffffc0204830 <commands+0x7c8>
ffffffffc0200c52:	078a                	slli	a5,a5,0x2
ffffffffc0200c54:	97ba                	add	a5,a5,a4
ffffffffc0200c56:	439c                	lw	a5,0(a5)
ffffffffc0200c58:	97ba                	add	a5,a5,a4
ffffffffc0200c5a:	8782                	jr	a5
        break;
    case CAUSE_LOAD_PAGE_FAULT:
        cprintf("Load page fault\n");
        break;
    case CAUSE_STORE_PAGE_FAULT:
        cprintf("Store/AMO page fault\n");
ffffffffc0200c5c:	00004517          	auipc	a0,0x4
ffffffffc0200c60:	bbc50513          	addi	a0,a0,-1092 # ffffffffc0204818 <commands+0x7b0>
ffffffffc0200c64:	d30ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Instruction address misaligned\n");
ffffffffc0200c68:	00004517          	auipc	a0,0x4
ffffffffc0200c6c:	a3050513          	addi	a0,a0,-1488 # ffffffffc0204698 <commands+0x630>
ffffffffc0200c70:	d24ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Instruction access fault\n");
ffffffffc0200c74:	00004517          	auipc	a0,0x4
ffffffffc0200c78:	a4450513          	addi	a0,a0,-1468 # ffffffffc02046b8 <commands+0x650>
ffffffffc0200c7c:	d18ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Illegal instruction\n");
ffffffffc0200c80:	00004517          	auipc	a0,0x4
ffffffffc0200c84:	a5850513          	addi	a0,a0,-1448 # ffffffffc02046d8 <commands+0x670>
ffffffffc0200c88:	d0cff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Breakpoint\n");
ffffffffc0200c8c:	00004517          	auipc	a0,0x4
ffffffffc0200c90:	a6450513          	addi	a0,a0,-1436 # ffffffffc02046f0 <commands+0x688>
ffffffffc0200c94:	d00ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Load address misaligned\n");
ffffffffc0200c98:	00004517          	auipc	a0,0x4
ffffffffc0200c9c:	a6850513          	addi	a0,a0,-1432 # ffffffffc0204700 <commands+0x698>
ffffffffc0200ca0:	cf4ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Load access fault\n");
ffffffffc0200ca4:	00004517          	auipc	a0,0x4
ffffffffc0200ca8:	a7c50513          	addi	a0,a0,-1412 # ffffffffc0204720 <commands+0x6b8>
ffffffffc0200cac:	ce8ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("AMO address misaligned\n");
ffffffffc0200cb0:	00004517          	auipc	a0,0x4
ffffffffc0200cb4:	a8850513          	addi	a0,a0,-1400 # ffffffffc0204738 <commands+0x6d0>
ffffffffc0200cb8:	cdcff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Store/AMO access fault\n");
ffffffffc0200cbc:	00004517          	auipc	a0,0x4
ffffffffc0200cc0:	a9450513          	addi	a0,a0,-1388 # ffffffffc0204750 <commands+0x6e8>
ffffffffc0200cc4:	cd0ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Environment call from U-mode\n");
ffffffffc0200cc8:	00004517          	auipc	a0,0x4
ffffffffc0200ccc:	aa050513          	addi	a0,a0,-1376 # ffffffffc0204768 <commands+0x700>
ffffffffc0200cd0:	cc4ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Environment call from S-mode\n");
ffffffffc0200cd4:	00004517          	auipc	a0,0x4
ffffffffc0200cd8:	ab450513          	addi	a0,a0,-1356 # ffffffffc0204788 <commands+0x720>
ffffffffc0200cdc:	cb8ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Environment call from H-mode\n");
ffffffffc0200ce0:	00004517          	auipc	a0,0x4
ffffffffc0200ce4:	ac850513          	addi	a0,a0,-1336 # ffffffffc02047a8 <commands+0x740>
ffffffffc0200ce8:	cacff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Environment call from M-mode\n");
ffffffffc0200cec:	00004517          	auipc	a0,0x4
ffffffffc0200cf0:	adc50513          	addi	a0,a0,-1316 # ffffffffc02047c8 <commands+0x760>
ffffffffc0200cf4:	ca0ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Instruction page fault\n");
ffffffffc0200cf8:	00004517          	auipc	a0,0x4
ffffffffc0200cfc:	af050513          	addi	a0,a0,-1296 # ffffffffc02047e8 <commands+0x780>
ffffffffc0200d00:	c94ff06f          	j	ffffffffc0200194 <cprintf>
        cprintf("Load page fault\n");
ffffffffc0200d04:	00004517          	auipc	a0,0x4
ffffffffc0200d08:	afc50513          	addi	a0,a0,-1284 # ffffffffc0204800 <commands+0x798>
ffffffffc0200d0c:	c88ff06f          	j	ffffffffc0200194 <cprintf>
        break;
    default:
        print_trapframe(tf);
ffffffffc0200d10:	bd01                	j	ffffffffc0200b20 <print_trapframe>

ffffffffc0200d12 <trap>:
 * trapframe and then uses the iret instruction to return from the exception.
 * */
void trap(struct trapframe *tf)
{
    // dispatch based on what type of trap occurred
    if ((intptr_t)tf->cause < 0)
ffffffffc0200d12:	11853783          	ld	a5,280(a0)
ffffffffc0200d16:	0007c363          	bltz	a5,ffffffffc0200d1c <trap+0xa>
        interrupt_handler(tf);
    }
    else
    {
        // exceptions
        exception_handler(tf);
ffffffffc0200d1a:	b71d                	j	ffffffffc0200c40 <exception_handler>
        interrupt_handler(tf);
ffffffffc0200d1c:	b59d                	j	ffffffffc0200b82 <interrupt_handler>
	...

ffffffffc0200d20 <__alltraps>:
    LOAD  x2,2*REGBYTES(sp)
    .endm

    .globl __alltraps
__alltraps:
    SAVE_ALL
ffffffffc0200d20:	14011073          	csrw	sscratch,sp
ffffffffc0200d24:	712d                	addi	sp,sp,-288
ffffffffc0200d26:	e406                	sd	ra,8(sp)
ffffffffc0200d28:	ec0e                	sd	gp,24(sp)
ffffffffc0200d2a:	f012                	sd	tp,32(sp)
ffffffffc0200d2c:	f416                	sd	t0,40(sp)
ffffffffc0200d2e:	f81a                	sd	t1,48(sp)
ffffffffc0200d30:	fc1e                	sd	t2,56(sp)
ffffffffc0200d32:	e0a2                	sd	s0,64(sp)
ffffffffc0200d34:	e4a6                	sd	s1,72(sp)
ffffffffc0200d36:	e8aa                	sd	a0,80(sp)
ffffffffc0200d38:	ecae                	sd	a1,88(sp)
ffffffffc0200d3a:	f0b2                	sd	a2,96(sp)
ffffffffc0200d3c:	f4b6                	sd	a3,104(sp)
ffffffffc0200d3e:	f8ba                	sd	a4,112(sp)
ffffffffc0200d40:	fcbe                	sd	a5,120(sp)
ffffffffc0200d42:	e142                	sd	a6,128(sp)
ffffffffc0200d44:	e546                	sd	a7,136(sp)
ffffffffc0200d46:	e94a                	sd	s2,144(sp)
ffffffffc0200d48:	ed4e                	sd	s3,152(sp)
ffffffffc0200d4a:	f152                	sd	s4,160(sp)
ffffffffc0200d4c:	f556                	sd	s5,168(sp)
ffffffffc0200d4e:	f95a                	sd	s6,176(sp)
ffffffffc0200d50:	fd5e                	sd	s7,184(sp)
ffffffffc0200d52:	e1e2                	sd	s8,192(sp)
ffffffffc0200d54:	e5e6                	sd	s9,200(sp)
ffffffffc0200d56:	e9ea                	sd	s10,208(sp)
ffffffffc0200d58:	edee                	sd	s11,216(sp)
ffffffffc0200d5a:	f1f2                	sd	t3,224(sp)
ffffffffc0200d5c:	f5f6                	sd	t4,232(sp)
ffffffffc0200d5e:	f9fa                	sd	t5,240(sp)
ffffffffc0200d60:	fdfe                	sd	t6,248(sp)
ffffffffc0200d62:	14002473          	csrr	s0,sscratch
ffffffffc0200d66:	100024f3          	csrr	s1,sstatus
ffffffffc0200d6a:	14102973          	csrr	s2,sepc
ffffffffc0200d6e:	143029f3          	csrr	s3,stval
ffffffffc0200d72:	14202a73          	csrr	s4,scause
ffffffffc0200d76:	e822                	sd	s0,16(sp)
ffffffffc0200d78:	e226                	sd	s1,256(sp)
ffffffffc0200d7a:	e64a                	sd	s2,264(sp)
ffffffffc0200d7c:	ea4e                	sd	s3,272(sp)
ffffffffc0200d7e:	ee52                	sd	s4,280(sp)

    move  a0, sp
ffffffffc0200d80:	850a                	mv	a0,sp
    jal trap
ffffffffc0200d82:	f91ff0ef          	jal	ra,ffffffffc0200d12 <trap>

ffffffffc0200d86 <__trapret>:
    # sp should be the same as before "jal trap"

    .globl __trapret
__trapret:
    RESTORE_ALL
ffffffffc0200d86:	6492                	ld	s1,256(sp)
ffffffffc0200d88:	6932                	ld	s2,264(sp)
ffffffffc0200d8a:	10049073          	csrw	sstatus,s1
ffffffffc0200d8e:	14191073          	csrw	sepc,s2
ffffffffc0200d92:	60a2                	ld	ra,8(sp)
ffffffffc0200d94:	61e2                	ld	gp,24(sp)
ffffffffc0200d96:	7202                	ld	tp,32(sp)
ffffffffc0200d98:	72a2                	ld	t0,40(sp)
ffffffffc0200d9a:	7342                	ld	t1,48(sp)
ffffffffc0200d9c:	73e2                	ld	t2,56(sp)
ffffffffc0200d9e:	6406                	ld	s0,64(sp)
ffffffffc0200da0:	64a6                	ld	s1,72(sp)
ffffffffc0200da2:	6546                	ld	a0,80(sp)
ffffffffc0200da4:	65e6                	ld	a1,88(sp)
ffffffffc0200da6:	7606                	ld	a2,96(sp)
ffffffffc0200da8:	76a6                	ld	a3,104(sp)
ffffffffc0200daa:	7746                	ld	a4,112(sp)
ffffffffc0200dac:	77e6                	ld	a5,120(sp)
ffffffffc0200dae:	680a                	ld	a6,128(sp)
ffffffffc0200db0:	68aa                	ld	a7,136(sp)
ffffffffc0200db2:	694a                	ld	s2,144(sp)
ffffffffc0200db4:	69ea                	ld	s3,152(sp)
ffffffffc0200db6:	7a0a                	ld	s4,160(sp)
ffffffffc0200db8:	7aaa                	ld	s5,168(sp)
ffffffffc0200dba:	7b4a                	ld	s6,176(sp)
ffffffffc0200dbc:	7bea                	ld	s7,184(sp)
ffffffffc0200dbe:	6c0e                	ld	s8,192(sp)
ffffffffc0200dc0:	6cae                	ld	s9,200(sp)
ffffffffc0200dc2:	6d4e                	ld	s10,208(sp)
ffffffffc0200dc4:	6dee                	ld	s11,216(sp)
ffffffffc0200dc6:	7e0e                	ld	t3,224(sp)
ffffffffc0200dc8:	7eae                	ld	t4,232(sp)
ffffffffc0200dca:	7f4e                	ld	t5,240(sp)
ffffffffc0200dcc:	7fee                	ld	t6,248(sp)
ffffffffc0200dce:	6142                	ld	sp,16(sp)
    # go back from supervisor call
    sret
ffffffffc0200dd0:	10200073          	sret

ffffffffc0200dd4 <forkrets>:
 
    .globl forkrets
forkrets:
    # set stack to this new process's trapframe
    move sp, a0
ffffffffc0200dd4:	812a                	mv	sp,a0
    j __trapret
ffffffffc0200dd6:	bf45                	j	ffffffffc0200d86 <__trapret>
	...

ffffffffc0200dda <best_fit_init>:
 * list_init - initialize a new entry
 * @elm:        new entry to be initialized
 * */
static inline void
list_init(list_entry_t *elm) {
    elm->prev = elm->next = elm;
ffffffffc0200dda:	00008797          	auipc	a5,0x8
ffffffffc0200dde:	65678793          	addi	a5,a5,1622 # ffffffffc0209430 <free_area>
ffffffffc0200de2:	e79c                	sd	a5,8(a5)
ffffffffc0200de4:	e39c                	sd	a5,0(a5)
#define nr_free (free_area.nr_free)

static void
best_fit_init(void) {
    list_init(&free_list);
    nr_free = 0;
ffffffffc0200de6:	0007a823          	sw	zero,16(a5)
}
ffffffffc0200dea:	8082                	ret

ffffffffc0200dec <best_fit_nr_free_pages>:
}

static size_t
best_fit_nr_free_pages(void) {
    return nr_free;
}
ffffffffc0200dec:	00008517          	auipc	a0,0x8
ffffffffc0200df0:	65456503          	lwu	a0,1620(a0) # ffffffffc0209440 <free_area+0x10>
ffffffffc0200df4:	8082                	ret

ffffffffc0200df6 <best_fit_alloc_pages>:
    assert(n > 0);
ffffffffc0200df6:	cd51                	beqz	a0,ffffffffc0200e92 <best_fit_alloc_pages+0x9c>
    if (n > nr_free) {
ffffffffc0200df8:	00008617          	auipc	a2,0x8
ffffffffc0200dfc:	63860613          	addi	a2,a2,1592 # ffffffffc0209430 <free_area>
ffffffffc0200e00:	01062803          	lw	a6,16(a2)
ffffffffc0200e04:	86aa                	mv	a3,a0
ffffffffc0200e06:	02081793          	slli	a5,a6,0x20
ffffffffc0200e0a:	9381                	srli	a5,a5,0x20
ffffffffc0200e0c:	08a7e163          	bltu	a5,a0,ffffffffc0200e8e <best_fit_alloc_pages+0x98>
 * list_next - get the next entry
 * @listelm:    the list head
 **/
static inline list_entry_t *
list_next(list_entry_t *listelm) {
    return listelm->next;
ffffffffc0200e10:	661c                	ld	a5,8(a2)
    size_t min_size = nr_free + 1;
ffffffffc0200e12:	0018059b          	addiw	a1,a6,1
ffffffffc0200e16:	1582                	slli	a1,a1,0x20
ffffffffc0200e18:	9181                	srli	a1,a1,0x20
    struct Page *page = NULL;
ffffffffc0200e1a:	4501                	li	a0,0
    while ((le = list_next(le)) != &free_list) {
ffffffffc0200e1c:	06c78863          	beq	a5,a2,ffffffffc0200e8c <best_fit_alloc_pages+0x96>
        if (p->property >= n) {
ffffffffc0200e20:	ff87e703          	lwu	a4,-8(a5)
ffffffffc0200e24:	00d76763          	bltu	a4,a3,ffffffffc0200e32 <best_fit_alloc_pages+0x3c>
            if (p->property < min_size) {
ffffffffc0200e28:	00b77563          	bgeu	a4,a1,ffffffffc0200e32 <best_fit_alloc_pages+0x3c>
        struct Page *p = le2page(le, page_link);
ffffffffc0200e2c:	fe878513          	addi	a0,a5,-24
ffffffffc0200e30:	85ba                	mv	a1,a4
ffffffffc0200e32:	679c                	ld	a5,8(a5)
    while ((le = list_next(le)) != &free_list) {
ffffffffc0200e34:	fec796e3          	bne	a5,a2,ffffffffc0200e20 <best_fit_alloc_pages+0x2a>
    if (page != NULL) {
ffffffffc0200e38:	c931                	beqz	a0,ffffffffc0200e8c <best_fit_alloc_pages+0x96>
    __list_del(listelm->prev, listelm->next);
ffffffffc0200e3a:	710c                	ld	a1,32(a0)
 * list_prev - get the previous entry
 * @listelm:    the list head
 **/
static inline list_entry_t *
list_prev(list_entry_t *listelm) {
    return listelm->prev;
ffffffffc0200e3c:	6d1c                	ld	a5,24(a0)
        if (page->property > n) {
ffffffffc0200e3e:	4918                	lw	a4,16(a0)
            p->property = page->property - n;
ffffffffc0200e40:	0006889b          	sext.w	a7,a3
 * This is only for internal list manipulation where we know
 * the prev/next entries already!
 * */
static inline void
__list_del(list_entry_t *prev, list_entry_t *next) {
    prev->next = next;
ffffffffc0200e44:	e78c                	sd	a1,8(a5)
    next->prev = prev;
ffffffffc0200e46:	e19c                	sd	a5,0(a1)
        if (page->property > n) {
ffffffffc0200e48:	02071593          	slli	a1,a4,0x20
ffffffffc0200e4c:	9181                	srli	a1,a1,0x20
ffffffffc0200e4e:	02b6f563          	bgeu	a3,a1,ffffffffc0200e78 <best_fit_alloc_pages+0x82>
            struct Page *p = page + n;
ffffffffc0200e52:	069a                	slli	a3,a3,0x6
ffffffffc0200e54:	96aa                	add	a3,a3,a0
            p->property = page->property - n;
ffffffffc0200e56:	4117073b          	subw	a4,a4,a7
ffffffffc0200e5a:	ca98                	sw	a4,16(a3)
 *
 * Note that @nr may be almost arbitrarily large; this function is not
 * restricted to acting on a single-word quantity.
 * */
static inline void set_bit(int nr, volatile void *addr) {
    __op_bit(or, __NOP, nr, ((volatile unsigned long *)addr));
ffffffffc0200e5c:	00868593          	addi	a1,a3,8
ffffffffc0200e60:	4709                	li	a4,2
ffffffffc0200e62:	40e5b02f          	amoor.d	zero,a4,(a1)
    __list_add(elm, listelm, listelm->next);
ffffffffc0200e66:	6798                	ld	a4,8(a5)
            list_add(prev, &(p->page_link));
ffffffffc0200e68:	01868593          	addi	a1,a3,24
        nr_free -= n;
ffffffffc0200e6c:	01062803          	lw	a6,16(a2)
    prev->next = next->prev = elm;
ffffffffc0200e70:	e30c                	sd	a1,0(a4)
ffffffffc0200e72:	e78c                	sd	a1,8(a5)
    elm->next = next;
ffffffffc0200e74:	f298                	sd	a4,32(a3)
    elm->prev = prev;
ffffffffc0200e76:	ee9c                	sd	a5,24(a3)
ffffffffc0200e78:	4118083b          	subw	a6,a6,a7
ffffffffc0200e7c:	01062823          	sw	a6,16(a2)
 * clear_bit - Atomically clears a bit in memory
 * @nr:     the bit to clear
 * @addr:   the address to start counting from
 * */
static inline void clear_bit(int nr, volatile void *addr) {
    __op_bit(and, __NOT, nr, ((volatile unsigned long *)addr));
ffffffffc0200e80:	57f5                	li	a5,-3
ffffffffc0200e82:	00850713          	addi	a4,a0,8
ffffffffc0200e86:	60f7302f          	amoand.d	zero,a5,(a4)
}
ffffffffc0200e8a:	8082                	ret
}
ffffffffc0200e8c:	8082                	ret
        return NULL;
ffffffffc0200e8e:	4501                	li	a0,0
ffffffffc0200e90:	8082                	ret
best_fit_alloc_pages(size_t n) {
ffffffffc0200e92:	1141                	addi	sp,sp,-16
    assert(n > 0);
ffffffffc0200e94:	00004697          	auipc	a3,0x4
ffffffffc0200e98:	9dc68693          	addi	a3,a3,-1572 # ffffffffc0204870 <commands+0x808>
ffffffffc0200e9c:	00004617          	auipc	a2,0x4
ffffffffc0200ea0:	9dc60613          	addi	a2,a2,-1572 # ffffffffc0204878 <commands+0x810>
ffffffffc0200ea4:	06c00593          	li	a1,108
ffffffffc0200ea8:	00004517          	auipc	a0,0x4
ffffffffc0200eac:	9e850513          	addi	a0,a0,-1560 # ffffffffc0204890 <commands+0x828>
best_fit_alloc_pages(size_t n) {
ffffffffc0200eb0:	e406                	sd	ra,8(sp)
    assert(n > 0);
ffffffffc0200eb2:	da8ff0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0200eb6 <best_fit_check>:
}

// LAB2: below code is used to check the best fit allocation algorithm (your EXERCISE 1) 
// NOTICE: You SHOULD NOT CHANGE basic_check, default_check functions!
static void
best_fit_check(void) {
ffffffffc0200eb6:	715d                	addi	sp,sp,-80
ffffffffc0200eb8:	e0a2                	sd	s0,64(sp)
    return listelm->next;
ffffffffc0200eba:	00008417          	auipc	s0,0x8
ffffffffc0200ebe:	57640413          	addi	s0,s0,1398 # ffffffffc0209430 <free_area>
ffffffffc0200ec2:	641c                	ld	a5,8(s0)
ffffffffc0200ec4:	e486                	sd	ra,72(sp)
ffffffffc0200ec6:	fc26                	sd	s1,56(sp)
ffffffffc0200ec8:	f84a                	sd	s2,48(sp)
ffffffffc0200eca:	f44e                	sd	s3,40(sp)
ffffffffc0200ecc:	f052                	sd	s4,32(sp)
ffffffffc0200ece:	ec56                	sd	s5,24(sp)
ffffffffc0200ed0:	e85a                	sd	s6,16(sp)
ffffffffc0200ed2:	e45e                	sd	s7,8(sp)
ffffffffc0200ed4:	e062                	sd	s8,0(sp)
    int score = 0 ,sumscore = 6;
    int count = 0, total = 0;
    list_entry_t *le = &free_list;
    while ((le = list_next(le)) != &free_list) {
ffffffffc0200ed6:	26878163          	beq	a5,s0,ffffffffc0201138 <best_fit_check+0x282>
    int count = 0, total = 0;
ffffffffc0200eda:	4481                	li	s1,0
ffffffffc0200edc:	4901                	li	s2,0
 * test_bit - Determine whether a bit is set
 * @nr:     the bit to test
 * @addr:   the address to count from
 * */
static inline bool test_bit(int nr, volatile void *addr) {
    return (((*(volatile unsigned long *)addr) >> nr) & 1);
ffffffffc0200ede:	ff07b703          	ld	a4,-16(a5)
        struct Page *p = le2page(le, page_link);
        assert(PageProperty(p));
ffffffffc0200ee2:	8b09                	andi	a4,a4,2
ffffffffc0200ee4:	24070e63          	beqz	a4,ffffffffc0201140 <best_fit_check+0x28a>
        count ++, total += p->property;
ffffffffc0200ee8:	ff87a703          	lw	a4,-8(a5)
ffffffffc0200eec:	679c                	ld	a5,8(a5)
ffffffffc0200eee:	2905                	addiw	s2,s2,1
ffffffffc0200ef0:	9cb9                	addw	s1,s1,a4
    while ((le = list_next(le)) != &free_list) {
ffffffffc0200ef2:	fe8796e3          	bne	a5,s0,ffffffffc0200ede <best_fit_check+0x28>
    }
    assert(total == nr_free_pages());
ffffffffc0200ef6:	89a6                	mv	s3,s1
ffffffffc0200ef8:	54f000ef          	jal	ra,ffffffffc0201c46 <nr_free_pages>
ffffffffc0200efc:	33351263          	bne	a0,s3,ffffffffc0201220 <best_fit_check+0x36a>
    assert((p0 = alloc_page()) != NULL);
ffffffffc0200f00:	4505                	li	a0,1
ffffffffc0200f02:	4c7000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc0200f06:	8aaa                	mv	s5,a0
ffffffffc0200f08:	34050c63          	beqz	a0,ffffffffc0201260 <best_fit_check+0x3aa>
    assert((p1 = alloc_page()) != NULL);
ffffffffc0200f0c:	4505                	li	a0,1
ffffffffc0200f0e:	4bb000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc0200f12:	89aa                	mv	s3,a0
ffffffffc0200f14:	32050663          	beqz	a0,ffffffffc0201240 <best_fit_check+0x38a>
    assert((p2 = alloc_page()) != NULL);
ffffffffc0200f18:	4505                	li	a0,1
ffffffffc0200f1a:	4af000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc0200f1e:	8a2a                	mv	s4,a0
ffffffffc0200f20:	2c050063          	beqz	a0,ffffffffc02011e0 <best_fit_check+0x32a>
    assert(p0 != p1 && p0 != p2 && p1 != p2);
ffffffffc0200f24:	233a8e63          	beq	s5,s3,ffffffffc0201160 <best_fit_check+0x2aa>
ffffffffc0200f28:	22aa8c63          	beq	s5,a0,ffffffffc0201160 <best_fit_check+0x2aa>
ffffffffc0200f2c:	22a98a63          	beq	s3,a0,ffffffffc0201160 <best_fit_check+0x2aa>
    assert(page_ref(p0) == 0 && page_ref(p1) == 0 && page_ref(p2) == 0);
ffffffffc0200f30:	000aa783          	lw	a5,0(s5)
ffffffffc0200f34:	24079663          	bnez	a5,ffffffffc0201180 <best_fit_check+0x2ca>
ffffffffc0200f38:	0009a783          	lw	a5,0(s3)
ffffffffc0200f3c:	24079263          	bnez	a5,ffffffffc0201180 <best_fit_check+0x2ca>
ffffffffc0200f40:	411c                	lw	a5,0(a0)
ffffffffc0200f42:	22079f63          	bnez	a5,ffffffffc0201180 <best_fit_check+0x2ca>
extern uint_t va_pa_offset;

static inline ppn_t
page2ppn(struct Page *page)
{
    return page - pages + nbase;
ffffffffc0200f46:	0000c797          	auipc	a5,0xc
ffffffffc0200f4a:	5727b783          	ld	a5,1394(a5) # ffffffffc020d4b8 <pages>
ffffffffc0200f4e:	40fa8733          	sub	a4,s5,a5
ffffffffc0200f52:	00005617          	auipc	a2,0x5
ffffffffc0200f56:	97e63603          	ld	a2,-1666(a2) # ffffffffc02058d0 <nbase>
ffffffffc0200f5a:	8719                	srai	a4,a4,0x6
ffffffffc0200f5c:	9732                	add	a4,a4,a2
    assert(page2pa(p0) < npage * PGSIZE);
ffffffffc0200f5e:	0000c697          	auipc	a3,0xc
ffffffffc0200f62:	5526b683          	ld	a3,1362(a3) # ffffffffc020d4b0 <npage>
ffffffffc0200f66:	06b2                	slli	a3,a3,0xc
}

static inline uintptr_t
page2pa(struct Page *page)
{
    return page2ppn(page) << PGSHIFT;
ffffffffc0200f68:	0732                	slli	a4,a4,0xc
ffffffffc0200f6a:	22d77b63          	bgeu	a4,a3,ffffffffc02011a0 <best_fit_check+0x2ea>
    return page - pages + nbase;
ffffffffc0200f6e:	40f98733          	sub	a4,s3,a5
ffffffffc0200f72:	8719                	srai	a4,a4,0x6
ffffffffc0200f74:	9732                	add	a4,a4,a2
    return page2ppn(page) << PGSHIFT;
ffffffffc0200f76:	0732                	slli	a4,a4,0xc
    assert(page2pa(p1) < npage * PGSIZE);
ffffffffc0200f78:	3ed77463          	bgeu	a4,a3,ffffffffc0201360 <best_fit_check+0x4aa>
    return page - pages + nbase;
ffffffffc0200f7c:	40f507b3          	sub	a5,a0,a5
ffffffffc0200f80:	8799                	srai	a5,a5,0x6
ffffffffc0200f82:	97b2                	add	a5,a5,a2
    return page2ppn(page) << PGSHIFT;
ffffffffc0200f84:	07b2                	slli	a5,a5,0xc
    assert(page2pa(p2) < npage * PGSIZE);
ffffffffc0200f86:	3ad7fd63          	bgeu	a5,a3,ffffffffc0201340 <best_fit_check+0x48a>
    assert(alloc_page() == NULL);
ffffffffc0200f8a:	4505                	li	a0,1
    list_entry_t free_list_store = free_list;
ffffffffc0200f8c:	00043c03          	ld	s8,0(s0)
ffffffffc0200f90:	00843b83          	ld	s7,8(s0)
    unsigned int nr_free_store = nr_free;
ffffffffc0200f94:	01042b03          	lw	s6,16(s0)
    elm->prev = elm->next = elm;
ffffffffc0200f98:	e400                	sd	s0,8(s0)
ffffffffc0200f9a:	e000                	sd	s0,0(s0)
    nr_free = 0;
ffffffffc0200f9c:	00008797          	auipc	a5,0x8
ffffffffc0200fa0:	4a07a223          	sw	zero,1188(a5) # ffffffffc0209440 <free_area+0x10>
    assert(alloc_page() == NULL);
ffffffffc0200fa4:	425000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc0200fa8:	36051c63          	bnez	a0,ffffffffc0201320 <best_fit_check+0x46a>
    free_page(p0);
ffffffffc0200fac:	4585                	li	a1,1
ffffffffc0200fae:	8556                	mv	a0,s5
ffffffffc0200fb0:	457000ef          	jal	ra,ffffffffc0201c06 <free_pages>
    free_page(p1);
ffffffffc0200fb4:	4585                	li	a1,1
ffffffffc0200fb6:	854e                	mv	a0,s3
ffffffffc0200fb8:	44f000ef          	jal	ra,ffffffffc0201c06 <free_pages>
    free_page(p2);
ffffffffc0200fbc:	4585                	li	a1,1
ffffffffc0200fbe:	8552                	mv	a0,s4
ffffffffc0200fc0:	447000ef          	jal	ra,ffffffffc0201c06 <free_pages>
    assert(nr_free == 3);
ffffffffc0200fc4:	4818                	lw	a4,16(s0)
ffffffffc0200fc6:	478d                	li	a5,3
ffffffffc0200fc8:	32f71c63          	bne	a4,a5,ffffffffc0201300 <best_fit_check+0x44a>
    assert((p0 = alloc_page()) != NULL);
ffffffffc0200fcc:	4505                	li	a0,1
ffffffffc0200fce:	3fb000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc0200fd2:	89aa                	mv	s3,a0
ffffffffc0200fd4:	30050663          	beqz	a0,ffffffffc02012e0 <best_fit_check+0x42a>
    assert((p1 = alloc_page()) != NULL);
ffffffffc0200fd8:	4505                	li	a0,1
ffffffffc0200fda:	3ef000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc0200fde:	8aaa                	mv	s5,a0
ffffffffc0200fe0:	2e050063          	beqz	a0,ffffffffc02012c0 <best_fit_check+0x40a>
    assert((p2 = alloc_page()) != NULL);
ffffffffc0200fe4:	4505                	li	a0,1
ffffffffc0200fe6:	3e3000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc0200fea:	8a2a                	mv	s4,a0
ffffffffc0200fec:	2a050a63          	beqz	a0,ffffffffc02012a0 <best_fit_check+0x3ea>
    assert(alloc_page() == NULL);
ffffffffc0200ff0:	4505                	li	a0,1
ffffffffc0200ff2:	3d7000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc0200ff6:	28051563          	bnez	a0,ffffffffc0201280 <best_fit_check+0x3ca>
    free_page(p0);
ffffffffc0200ffa:	4585                	li	a1,1
ffffffffc0200ffc:	854e                	mv	a0,s3
ffffffffc0200ffe:	409000ef          	jal	ra,ffffffffc0201c06 <free_pages>
    assert(!list_empty(&free_list));
ffffffffc0201002:	641c                	ld	a5,8(s0)
ffffffffc0201004:	1a878e63          	beq	a5,s0,ffffffffc02011c0 <best_fit_check+0x30a>
    assert((p = alloc_page()) == p0);
ffffffffc0201008:	4505                	li	a0,1
ffffffffc020100a:	3bf000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc020100e:	52a99963          	bne	s3,a0,ffffffffc0201540 <best_fit_check+0x68a>
    assert(alloc_page() == NULL);
ffffffffc0201012:	4505                	li	a0,1
ffffffffc0201014:	3b5000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc0201018:	50051463          	bnez	a0,ffffffffc0201520 <best_fit_check+0x66a>
    assert(nr_free == 0);
ffffffffc020101c:	481c                	lw	a5,16(s0)
ffffffffc020101e:	4e079163          	bnez	a5,ffffffffc0201500 <best_fit_check+0x64a>
    free_page(p);
ffffffffc0201022:	854e                	mv	a0,s3
ffffffffc0201024:	4585                	li	a1,1
    free_list = free_list_store;
ffffffffc0201026:	01843023          	sd	s8,0(s0)
ffffffffc020102a:	01743423          	sd	s7,8(s0)
    nr_free = nr_free_store;
ffffffffc020102e:	01642823          	sw	s6,16(s0)
    free_page(p);
ffffffffc0201032:	3d5000ef          	jal	ra,ffffffffc0201c06 <free_pages>
    free_page(p1);
ffffffffc0201036:	4585                	li	a1,1
ffffffffc0201038:	8556                	mv	a0,s5
ffffffffc020103a:	3cd000ef          	jal	ra,ffffffffc0201c06 <free_pages>
    free_page(p2);
ffffffffc020103e:	4585                	li	a1,1
ffffffffc0201040:	8552                	mv	a0,s4
ffffffffc0201042:	3c5000ef          	jal	ra,ffffffffc0201c06 <free_pages>

    #ifdef ucore_test
    score += 1;
    cprintf("grading: %d / %d points\n",score, sumscore);
    #endif
    struct Page *p0 = alloc_pages(5), *p1, *p2;
ffffffffc0201046:	4515                	li	a0,5
ffffffffc0201048:	381000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc020104c:	89aa                	mv	s3,a0
    assert(p0 != NULL);
ffffffffc020104e:	48050963          	beqz	a0,ffffffffc02014e0 <best_fit_check+0x62a>
ffffffffc0201052:	651c                	ld	a5,8(a0)
ffffffffc0201054:	8385                	srli	a5,a5,0x1
    assert(!PageProperty(p0));
ffffffffc0201056:	8b85                	andi	a5,a5,1
ffffffffc0201058:	46079463          	bnez	a5,ffffffffc02014c0 <best_fit_check+0x60a>
    cprintf("grading: %d / %d points\n",score, sumscore);
    #endif
    list_entry_t free_list_store = free_list;
    list_init(&free_list);
    assert(list_empty(&free_list));
    assert(alloc_page() == NULL);
ffffffffc020105c:	4505                	li	a0,1
    list_entry_t free_list_store = free_list;
ffffffffc020105e:	00043a83          	ld	s5,0(s0)
ffffffffc0201062:	00843a03          	ld	s4,8(s0)
ffffffffc0201066:	e000                	sd	s0,0(s0)
ffffffffc0201068:	e400                	sd	s0,8(s0)
    assert(alloc_page() == NULL);
ffffffffc020106a:	35f000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc020106e:	42051963          	bnez	a0,ffffffffc02014a0 <best_fit_check+0x5ea>
    #endif
    unsigned int nr_free_store = nr_free;
    nr_free = 0;

    // * - - * -
    free_pages(p0 + 1, 2);
ffffffffc0201072:	4589                	li	a1,2
ffffffffc0201074:	04098513          	addi	a0,s3,64
    unsigned int nr_free_store = nr_free;
ffffffffc0201078:	01042b03          	lw	s6,16(s0)
    free_pages(p0 + 4, 1);
ffffffffc020107c:	10098c13          	addi	s8,s3,256
    nr_free = 0;
ffffffffc0201080:	00008797          	auipc	a5,0x8
ffffffffc0201084:	3c07a023          	sw	zero,960(a5) # ffffffffc0209440 <free_area+0x10>
    free_pages(p0 + 1, 2);
ffffffffc0201088:	37f000ef          	jal	ra,ffffffffc0201c06 <free_pages>
    free_pages(p0 + 4, 1);
ffffffffc020108c:	8562                	mv	a0,s8
ffffffffc020108e:	4585                	li	a1,1
ffffffffc0201090:	377000ef          	jal	ra,ffffffffc0201c06 <free_pages>
    assert(alloc_pages(4) == NULL);
ffffffffc0201094:	4511                	li	a0,4
ffffffffc0201096:	333000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc020109a:	3e051363          	bnez	a0,ffffffffc0201480 <best_fit_check+0x5ca>
ffffffffc020109e:	0489b783          	ld	a5,72(s3)
ffffffffc02010a2:	8385                	srli	a5,a5,0x1
    assert(PageProperty(p0 + 1) && p0[1].property == 2);
ffffffffc02010a4:	8b85                	andi	a5,a5,1
ffffffffc02010a6:	3a078d63          	beqz	a5,ffffffffc0201460 <best_fit_check+0x5aa>
ffffffffc02010aa:	0509a703          	lw	a4,80(s3)
ffffffffc02010ae:	4789                	li	a5,2
ffffffffc02010b0:	3af71863          	bne	a4,a5,ffffffffc0201460 <best_fit_check+0x5aa>
    // * - - * *
    assert((p1 = alloc_pages(1)) != NULL);
ffffffffc02010b4:	4505                	li	a0,1
ffffffffc02010b6:	313000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc02010ba:	8baa                	mv	s7,a0
ffffffffc02010bc:	38050263          	beqz	a0,ffffffffc0201440 <best_fit_check+0x58a>
    assert(alloc_pages(2) != NULL);      // best fit feature
ffffffffc02010c0:	4509                	li	a0,2
ffffffffc02010c2:	307000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc02010c6:	34050d63          	beqz	a0,ffffffffc0201420 <best_fit_check+0x56a>
    assert(p0 + 4 == p1);
ffffffffc02010ca:	337c1b63          	bne	s8,s7,ffffffffc0201400 <best_fit_check+0x54a>
    #ifdef ucore_test
    score += 1;
    cprintf("grading: %d / %d points\n",score, sumscore);
    #endif
    p2 = p0 + 1;
    free_pages(p0, 5);
ffffffffc02010ce:	854e                	mv	a0,s3
ffffffffc02010d0:	4595                	li	a1,5
ffffffffc02010d2:	335000ef          	jal	ra,ffffffffc0201c06 <free_pages>
    assert((p0 = alloc_pages(5)) != NULL);
ffffffffc02010d6:	4515                	li	a0,5
ffffffffc02010d8:	2f1000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc02010dc:	89aa                	mv	s3,a0
ffffffffc02010de:	30050163          	beqz	a0,ffffffffc02013e0 <best_fit_check+0x52a>
    assert(alloc_page() == NULL);
ffffffffc02010e2:	4505                	li	a0,1
ffffffffc02010e4:	2e5000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
ffffffffc02010e8:	2c051c63          	bnez	a0,ffffffffc02013c0 <best_fit_check+0x50a>

    #ifdef ucore_test
    score += 1;
    cprintf("grading: %d / %d points\n",score, sumscore);
    #endif
    assert(nr_free == 0);
ffffffffc02010ec:	481c                	lw	a5,16(s0)
ffffffffc02010ee:	2a079963          	bnez	a5,ffffffffc02013a0 <best_fit_check+0x4ea>
    nr_free = nr_free_store;

    free_list = free_list_store;
    free_pages(p0, 5);
ffffffffc02010f2:	4595                	li	a1,5
ffffffffc02010f4:	854e                	mv	a0,s3
    nr_free = nr_free_store;
ffffffffc02010f6:	01642823          	sw	s6,16(s0)
    free_list = free_list_store;
ffffffffc02010fa:	01543023          	sd	s5,0(s0)
ffffffffc02010fe:	01443423          	sd	s4,8(s0)
    free_pages(p0, 5);
ffffffffc0201102:	305000ef          	jal	ra,ffffffffc0201c06 <free_pages>
    return listelm->next;
ffffffffc0201106:	641c                	ld	a5,8(s0)

    le = &free_list;
    while ((le = list_next(le)) != &free_list) {
ffffffffc0201108:	00878963          	beq	a5,s0,ffffffffc020111a <best_fit_check+0x264>
        struct Page *p = le2page(le, page_link);
        count --, total -= p->property;
ffffffffc020110c:	ff87a703          	lw	a4,-8(a5)
ffffffffc0201110:	679c                	ld	a5,8(a5)
ffffffffc0201112:	397d                	addiw	s2,s2,-1
ffffffffc0201114:	9c99                	subw	s1,s1,a4
    while ((le = list_next(le)) != &free_list) {
ffffffffc0201116:	fe879be3          	bne	a5,s0,ffffffffc020110c <best_fit_check+0x256>
    }
    assert(count == 0);
ffffffffc020111a:	26091363          	bnez	s2,ffffffffc0201380 <best_fit_check+0x4ca>
    assert(total == 0);
ffffffffc020111e:	e0ed                	bnez	s1,ffffffffc0201200 <best_fit_check+0x34a>
    #ifdef ucore_test
    score += 1;
    cprintf("grading: %d / %d points\n",score, sumscore);
    #endif
}
ffffffffc0201120:	60a6                	ld	ra,72(sp)
ffffffffc0201122:	6406                	ld	s0,64(sp)
ffffffffc0201124:	74e2                	ld	s1,56(sp)
ffffffffc0201126:	7942                	ld	s2,48(sp)
ffffffffc0201128:	79a2                	ld	s3,40(sp)
ffffffffc020112a:	7a02                	ld	s4,32(sp)
ffffffffc020112c:	6ae2                	ld	s5,24(sp)
ffffffffc020112e:	6b42                	ld	s6,16(sp)
ffffffffc0201130:	6ba2                	ld	s7,8(sp)
ffffffffc0201132:	6c02                	ld	s8,0(sp)
ffffffffc0201134:	6161                	addi	sp,sp,80
ffffffffc0201136:	8082                	ret
    while ((le = list_next(le)) != &free_list) {
ffffffffc0201138:	4981                	li	s3,0
    int count = 0, total = 0;
ffffffffc020113a:	4481                	li	s1,0
ffffffffc020113c:	4901                	li	s2,0
ffffffffc020113e:	bb6d                	j	ffffffffc0200ef8 <best_fit_check+0x42>
        assert(PageProperty(p));
ffffffffc0201140:	00003697          	auipc	a3,0x3
ffffffffc0201144:	76868693          	addi	a3,a3,1896 # ffffffffc02048a8 <commands+0x840>
ffffffffc0201148:	00003617          	auipc	a2,0x3
ffffffffc020114c:	73060613          	addi	a2,a2,1840 # ffffffffc0204878 <commands+0x810>
ffffffffc0201150:	11100593          	li	a1,273
ffffffffc0201154:	00003517          	auipc	a0,0x3
ffffffffc0201158:	73c50513          	addi	a0,a0,1852 # ffffffffc0204890 <commands+0x828>
ffffffffc020115c:	afeff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(p0 != p1 && p0 != p2 && p1 != p2);
ffffffffc0201160:	00003697          	auipc	a3,0x3
ffffffffc0201164:	7d868693          	addi	a3,a3,2008 # ffffffffc0204938 <commands+0x8d0>
ffffffffc0201168:	00003617          	auipc	a2,0x3
ffffffffc020116c:	71060613          	addi	a2,a2,1808 # ffffffffc0204878 <commands+0x810>
ffffffffc0201170:	0dd00593          	li	a1,221
ffffffffc0201174:	00003517          	auipc	a0,0x3
ffffffffc0201178:	71c50513          	addi	a0,a0,1820 # ffffffffc0204890 <commands+0x828>
ffffffffc020117c:	adeff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(p0) == 0 && page_ref(p1) == 0 && page_ref(p2) == 0);
ffffffffc0201180:	00003697          	auipc	a3,0x3
ffffffffc0201184:	7e068693          	addi	a3,a3,2016 # ffffffffc0204960 <commands+0x8f8>
ffffffffc0201188:	00003617          	auipc	a2,0x3
ffffffffc020118c:	6f060613          	addi	a2,a2,1776 # ffffffffc0204878 <commands+0x810>
ffffffffc0201190:	0de00593          	li	a1,222
ffffffffc0201194:	00003517          	auipc	a0,0x3
ffffffffc0201198:	6fc50513          	addi	a0,a0,1788 # ffffffffc0204890 <commands+0x828>
ffffffffc020119c:	abeff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page2pa(p0) < npage * PGSIZE);
ffffffffc02011a0:	00004697          	auipc	a3,0x4
ffffffffc02011a4:	80068693          	addi	a3,a3,-2048 # ffffffffc02049a0 <commands+0x938>
ffffffffc02011a8:	00003617          	auipc	a2,0x3
ffffffffc02011ac:	6d060613          	addi	a2,a2,1744 # ffffffffc0204878 <commands+0x810>
ffffffffc02011b0:	0e000593          	li	a1,224
ffffffffc02011b4:	00003517          	auipc	a0,0x3
ffffffffc02011b8:	6dc50513          	addi	a0,a0,1756 # ffffffffc0204890 <commands+0x828>
ffffffffc02011bc:	a9eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(!list_empty(&free_list));
ffffffffc02011c0:	00004697          	auipc	a3,0x4
ffffffffc02011c4:	86868693          	addi	a3,a3,-1944 # ffffffffc0204a28 <commands+0x9c0>
ffffffffc02011c8:	00003617          	auipc	a2,0x3
ffffffffc02011cc:	6b060613          	addi	a2,a2,1712 # ffffffffc0204878 <commands+0x810>
ffffffffc02011d0:	0f900593          	li	a1,249
ffffffffc02011d4:	00003517          	auipc	a0,0x3
ffffffffc02011d8:	6bc50513          	addi	a0,a0,1724 # ffffffffc0204890 <commands+0x828>
ffffffffc02011dc:	a7eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((p2 = alloc_page()) != NULL);
ffffffffc02011e0:	00003697          	auipc	a3,0x3
ffffffffc02011e4:	73868693          	addi	a3,a3,1848 # ffffffffc0204918 <commands+0x8b0>
ffffffffc02011e8:	00003617          	auipc	a2,0x3
ffffffffc02011ec:	69060613          	addi	a2,a2,1680 # ffffffffc0204878 <commands+0x810>
ffffffffc02011f0:	0db00593          	li	a1,219
ffffffffc02011f4:	00003517          	auipc	a0,0x3
ffffffffc02011f8:	69c50513          	addi	a0,a0,1692 # ffffffffc0204890 <commands+0x828>
ffffffffc02011fc:	a5eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(total == 0);
ffffffffc0201200:	00004697          	auipc	a3,0x4
ffffffffc0201204:	95868693          	addi	a3,a3,-1704 # ffffffffc0204b58 <commands+0xaf0>
ffffffffc0201208:	00003617          	auipc	a2,0x3
ffffffffc020120c:	67060613          	addi	a2,a2,1648 # ffffffffc0204878 <commands+0x810>
ffffffffc0201210:	15300593          	li	a1,339
ffffffffc0201214:	00003517          	auipc	a0,0x3
ffffffffc0201218:	67c50513          	addi	a0,a0,1660 # ffffffffc0204890 <commands+0x828>
ffffffffc020121c:	a3eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(total == nr_free_pages());
ffffffffc0201220:	00003697          	auipc	a3,0x3
ffffffffc0201224:	69868693          	addi	a3,a3,1688 # ffffffffc02048b8 <commands+0x850>
ffffffffc0201228:	00003617          	auipc	a2,0x3
ffffffffc020122c:	65060613          	addi	a2,a2,1616 # ffffffffc0204878 <commands+0x810>
ffffffffc0201230:	11400593          	li	a1,276
ffffffffc0201234:	00003517          	auipc	a0,0x3
ffffffffc0201238:	65c50513          	addi	a0,a0,1628 # ffffffffc0204890 <commands+0x828>
ffffffffc020123c:	a1eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((p1 = alloc_page()) != NULL);
ffffffffc0201240:	00003697          	auipc	a3,0x3
ffffffffc0201244:	6b868693          	addi	a3,a3,1720 # ffffffffc02048f8 <commands+0x890>
ffffffffc0201248:	00003617          	auipc	a2,0x3
ffffffffc020124c:	63060613          	addi	a2,a2,1584 # ffffffffc0204878 <commands+0x810>
ffffffffc0201250:	0da00593          	li	a1,218
ffffffffc0201254:	00003517          	auipc	a0,0x3
ffffffffc0201258:	63c50513          	addi	a0,a0,1596 # ffffffffc0204890 <commands+0x828>
ffffffffc020125c:	9feff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((p0 = alloc_page()) != NULL);
ffffffffc0201260:	00003697          	auipc	a3,0x3
ffffffffc0201264:	67868693          	addi	a3,a3,1656 # ffffffffc02048d8 <commands+0x870>
ffffffffc0201268:	00003617          	auipc	a2,0x3
ffffffffc020126c:	61060613          	addi	a2,a2,1552 # ffffffffc0204878 <commands+0x810>
ffffffffc0201270:	0d900593          	li	a1,217
ffffffffc0201274:	00003517          	auipc	a0,0x3
ffffffffc0201278:	61c50513          	addi	a0,a0,1564 # ffffffffc0204890 <commands+0x828>
ffffffffc020127c:	9deff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(alloc_page() == NULL);
ffffffffc0201280:	00003697          	auipc	a3,0x3
ffffffffc0201284:	78068693          	addi	a3,a3,1920 # ffffffffc0204a00 <commands+0x998>
ffffffffc0201288:	00003617          	auipc	a2,0x3
ffffffffc020128c:	5f060613          	addi	a2,a2,1520 # ffffffffc0204878 <commands+0x810>
ffffffffc0201290:	0f600593          	li	a1,246
ffffffffc0201294:	00003517          	auipc	a0,0x3
ffffffffc0201298:	5fc50513          	addi	a0,a0,1532 # ffffffffc0204890 <commands+0x828>
ffffffffc020129c:	9beff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((p2 = alloc_page()) != NULL);
ffffffffc02012a0:	00003697          	auipc	a3,0x3
ffffffffc02012a4:	67868693          	addi	a3,a3,1656 # ffffffffc0204918 <commands+0x8b0>
ffffffffc02012a8:	00003617          	auipc	a2,0x3
ffffffffc02012ac:	5d060613          	addi	a2,a2,1488 # ffffffffc0204878 <commands+0x810>
ffffffffc02012b0:	0f400593          	li	a1,244
ffffffffc02012b4:	00003517          	auipc	a0,0x3
ffffffffc02012b8:	5dc50513          	addi	a0,a0,1500 # ffffffffc0204890 <commands+0x828>
ffffffffc02012bc:	99eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((p1 = alloc_page()) != NULL);
ffffffffc02012c0:	00003697          	auipc	a3,0x3
ffffffffc02012c4:	63868693          	addi	a3,a3,1592 # ffffffffc02048f8 <commands+0x890>
ffffffffc02012c8:	00003617          	auipc	a2,0x3
ffffffffc02012cc:	5b060613          	addi	a2,a2,1456 # ffffffffc0204878 <commands+0x810>
ffffffffc02012d0:	0f300593          	li	a1,243
ffffffffc02012d4:	00003517          	auipc	a0,0x3
ffffffffc02012d8:	5bc50513          	addi	a0,a0,1468 # ffffffffc0204890 <commands+0x828>
ffffffffc02012dc:	97eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((p0 = alloc_page()) != NULL);
ffffffffc02012e0:	00003697          	auipc	a3,0x3
ffffffffc02012e4:	5f868693          	addi	a3,a3,1528 # ffffffffc02048d8 <commands+0x870>
ffffffffc02012e8:	00003617          	auipc	a2,0x3
ffffffffc02012ec:	59060613          	addi	a2,a2,1424 # ffffffffc0204878 <commands+0x810>
ffffffffc02012f0:	0f200593          	li	a1,242
ffffffffc02012f4:	00003517          	auipc	a0,0x3
ffffffffc02012f8:	59c50513          	addi	a0,a0,1436 # ffffffffc0204890 <commands+0x828>
ffffffffc02012fc:	95eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(nr_free == 3);
ffffffffc0201300:	00003697          	auipc	a3,0x3
ffffffffc0201304:	71868693          	addi	a3,a3,1816 # ffffffffc0204a18 <commands+0x9b0>
ffffffffc0201308:	00003617          	auipc	a2,0x3
ffffffffc020130c:	57060613          	addi	a2,a2,1392 # ffffffffc0204878 <commands+0x810>
ffffffffc0201310:	0f000593          	li	a1,240
ffffffffc0201314:	00003517          	auipc	a0,0x3
ffffffffc0201318:	57c50513          	addi	a0,a0,1404 # ffffffffc0204890 <commands+0x828>
ffffffffc020131c:	93eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(alloc_page() == NULL);
ffffffffc0201320:	00003697          	auipc	a3,0x3
ffffffffc0201324:	6e068693          	addi	a3,a3,1760 # ffffffffc0204a00 <commands+0x998>
ffffffffc0201328:	00003617          	auipc	a2,0x3
ffffffffc020132c:	55060613          	addi	a2,a2,1360 # ffffffffc0204878 <commands+0x810>
ffffffffc0201330:	0eb00593          	li	a1,235
ffffffffc0201334:	00003517          	auipc	a0,0x3
ffffffffc0201338:	55c50513          	addi	a0,a0,1372 # ffffffffc0204890 <commands+0x828>
ffffffffc020133c:	91eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page2pa(p2) < npage * PGSIZE);
ffffffffc0201340:	00003697          	auipc	a3,0x3
ffffffffc0201344:	6a068693          	addi	a3,a3,1696 # ffffffffc02049e0 <commands+0x978>
ffffffffc0201348:	00003617          	auipc	a2,0x3
ffffffffc020134c:	53060613          	addi	a2,a2,1328 # ffffffffc0204878 <commands+0x810>
ffffffffc0201350:	0e200593          	li	a1,226
ffffffffc0201354:	00003517          	auipc	a0,0x3
ffffffffc0201358:	53c50513          	addi	a0,a0,1340 # ffffffffc0204890 <commands+0x828>
ffffffffc020135c:	8feff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page2pa(p1) < npage * PGSIZE);
ffffffffc0201360:	00003697          	auipc	a3,0x3
ffffffffc0201364:	66068693          	addi	a3,a3,1632 # ffffffffc02049c0 <commands+0x958>
ffffffffc0201368:	00003617          	auipc	a2,0x3
ffffffffc020136c:	51060613          	addi	a2,a2,1296 # ffffffffc0204878 <commands+0x810>
ffffffffc0201370:	0e100593          	li	a1,225
ffffffffc0201374:	00003517          	auipc	a0,0x3
ffffffffc0201378:	51c50513          	addi	a0,a0,1308 # ffffffffc0204890 <commands+0x828>
ffffffffc020137c:	8deff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(count == 0);
ffffffffc0201380:	00003697          	auipc	a3,0x3
ffffffffc0201384:	7c868693          	addi	a3,a3,1992 # ffffffffc0204b48 <commands+0xae0>
ffffffffc0201388:	00003617          	auipc	a2,0x3
ffffffffc020138c:	4f060613          	addi	a2,a2,1264 # ffffffffc0204878 <commands+0x810>
ffffffffc0201390:	15200593          	li	a1,338
ffffffffc0201394:	00003517          	auipc	a0,0x3
ffffffffc0201398:	4fc50513          	addi	a0,a0,1276 # ffffffffc0204890 <commands+0x828>
ffffffffc020139c:	8beff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(nr_free == 0);
ffffffffc02013a0:	00003697          	auipc	a3,0x3
ffffffffc02013a4:	6c068693          	addi	a3,a3,1728 # ffffffffc0204a60 <commands+0x9f8>
ffffffffc02013a8:	00003617          	auipc	a2,0x3
ffffffffc02013ac:	4d060613          	addi	a2,a2,1232 # ffffffffc0204878 <commands+0x810>
ffffffffc02013b0:	14700593          	li	a1,327
ffffffffc02013b4:	00003517          	auipc	a0,0x3
ffffffffc02013b8:	4dc50513          	addi	a0,a0,1244 # ffffffffc0204890 <commands+0x828>
ffffffffc02013bc:	89eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(alloc_page() == NULL);
ffffffffc02013c0:	00003697          	auipc	a3,0x3
ffffffffc02013c4:	64068693          	addi	a3,a3,1600 # ffffffffc0204a00 <commands+0x998>
ffffffffc02013c8:	00003617          	auipc	a2,0x3
ffffffffc02013cc:	4b060613          	addi	a2,a2,1200 # ffffffffc0204878 <commands+0x810>
ffffffffc02013d0:	14100593          	li	a1,321
ffffffffc02013d4:	00003517          	auipc	a0,0x3
ffffffffc02013d8:	4bc50513          	addi	a0,a0,1212 # ffffffffc0204890 <commands+0x828>
ffffffffc02013dc:	87eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((p0 = alloc_pages(5)) != NULL);
ffffffffc02013e0:	00003697          	auipc	a3,0x3
ffffffffc02013e4:	74868693          	addi	a3,a3,1864 # ffffffffc0204b28 <commands+0xac0>
ffffffffc02013e8:	00003617          	auipc	a2,0x3
ffffffffc02013ec:	49060613          	addi	a2,a2,1168 # ffffffffc0204878 <commands+0x810>
ffffffffc02013f0:	14000593          	li	a1,320
ffffffffc02013f4:	00003517          	auipc	a0,0x3
ffffffffc02013f8:	49c50513          	addi	a0,a0,1180 # ffffffffc0204890 <commands+0x828>
ffffffffc02013fc:	85eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(p0 + 4 == p1);
ffffffffc0201400:	00003697          	auipc	a3,0x3
ffffffffc0201404:	71868693          	addi	a3,a3,1816 # ffffffffc0204b18 <commands+0xab0>
ffffffffc0201408:	00003617          	auipc	a2,0x3
ffffffffc020140c:	47060613          	addi	a2,a2,1136 # ffffffffc0204878 <commands+0x810>
ffffffffc0201410:	13800593          	li	a1,312
ffffffffc0201414:	00003517          	auipc	a0,0x3
ffffffffc0201418:	47c50513          	addi	a0,a0,1148 # ffffffffc0204890 <commands+0x828>
ffffffffc020141c:	83eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(alloc_pages(2) != NULL);      // best fit feature
ffffffffc0201420:	00003697          	auipc	a3,0x3
ffffffffc0201424:	6e068693          	addi	a3,a3,1760 # ffffffffc0204b00 <commands+0xa98>
ffffffffc0201428:	00003617          	auipc	a2,0x3
ffffffffc020142c:	45060613          	addi	a2,a2,1104 # ffffffffc0204878 <commands+0x810>
ffffffffc0201430:	13700593          	li	a1,311
ffffffffc0201434:	00003517          	auipc	a0,0x3
ffffffffc0201438:	45c50513          	addi	a0,a0,1116 # ffffffffc0204890 <commands+0x828>
ffffffffc020143c:	81eff0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((p1 = alloc_pages(1)) != NULL);
ffffffffc0201440:	00003697          	auipc	a3,0x3
ffffffffc0201444:	6a068693          	addi	a3,a3,1696 # ffffffffc0204ae0 <commands+0xa78>
ffffffffc0201448:	00003617          	auipc	a2,0x3
ffffffffc020144c:	43060613          	addi	a2,a2,1072 # ffffffffc0204878 <commands+0x810>
ffffffffc0201450:	13600593          	li	a1,310
ffffffffc0201454:	00003517          	auipc	a0,0x3
ffffffffc0201458:	43c50513          	addi	a0,a0,1084 # ffffffffc0204890 <commands+0x828>
ffffffffc020145c:	ffffe0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(PageProperty(p0 + 1) && p0[1].property == 2);
ffffffffc0201460:	00003697          	auipc	a3,0x3
ffffffffc0201464:	65068693          	addi	a3,a3,1616 # ffffffffc0204ab0 <commands+0xa48>
ffffffffc0201468:	00003617          	auipc	a2,0x3
ffffffffc020146c:	41060613          	addi	a2,a2,1040 # ffffffffc0204878 <commands+0x810>
ffffffffc0201470:	13400593          	li	a1,308
ffffffffc0201474:	00003517          	auipc	a0,0x3
ffffffffc0201478:	41c50513          	addi	a0,a0,1052 # ffffffffc0204890 <commands+0x828>
ffffffffc020147c:	fdffe0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(alloc_pages(4) == NULL);
ffffffffc0201480:	00003697          	auipc	a3,0x3
ffffffffc0201484:	61868693          	addi	a3,a3,1560 # ffffffffc0204a98 <commands+0xa30>
ffffffffc0201488:	00003617          	auipc	a2,0x3
ffffffffc020148c:	3f060613          	addi	a2,a2,1008 # ffffffffc0204878 <commands+0x810>
ffffffffc0201490:	13300593          	li	a1,307
ffffffffc0201494:	00003517          	auipc	a0,0x3
ffffffffc0201498:	3fc50513          	addi	a0,a0,1020 # ffffffffc0204890 <commands+0x828>
ffffffffc020149c:	fbffe0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(alloc_page() == NULL);
ffffffffc02014a0:	00003697          	auipc	a3,0x3
ffffffffc02014a4:	56068693          	addi	a3,a3,1376 # ffffffffc0204a00 <commands+0x998>
ffffffffc02014a8:	00003617          	auipc	a2,0x3
ffffffffc02014ac:	3d060613          	addi	a2,a2,976 # ffffffffc0204878 <commands+0x810>
ffffffffc02014b0:	12700593          	li	a1,295
ffffffffc02014b4:	00003517          	auipc	a0,0x3
ffffffffc02014b8:	3dc50513          	addi	a0,a0,988 # ffffffffc0204890 <commands+0x828>
ffffffffc02014bc:	f9ffe0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(!PageProperty(p0));
ffffffffc02014c0:	00003697          	auipc	a3,0x3
ffffffffc02014c4:	5c068693          	addi	a3,a3,1472 # ffffffffc0204a80 <commands+0xa18>
ffffffffc02014c8:	00003617          	auipc	a2,0x3
ffffffffc02014cc:	3b060613          	addi	a2,a2,944 # ffffffffc0204878 <commands+0x810>
ffffffffc02014d0:	11e00593          	li	a1,286
ffffffffc02014d4:	00003517          	auipc	a0,0x3
ffffffffc02014d8:	3bc50513          	addi	a0,a0,956 # ffffffffc0204890 <commands+0x828>
ffffffffc02014dc:	f7ffe0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(p0 != NULL);
ffffffffc02014e0:	00003697          	auipc	a3,0x3
ffffffffc02014e4:	59068693          	addi	a3,a3,1424 # ffffffffc0204a70 <commands+0xa08>
ffffffffc02014e8:	00003617          	auipc	a2,0x3
ffffffffc02014ec:	39060613          	addi	a2,a2,912 # ffffffffc0204878 <commands+0x810>
ffffffffc02014f0:	11d00593          	li	a1,285
ffffffffc02014f4:	00003517          	auipc	a0,0x3
ffffffffc02014f8:	39c50513          	addi	a0,a0,924 # ffffffffc0204890 <commands+0x828>
ffffffffc02014fc:	f5ffe0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(nr_free == 0);
ffffffffc0201500:	00003697          	auipc	a3,0x3
ffffffffc0201504:	56068693          	addi	a3,a3,1376 # ffffffffc0204a60 <commands+0x9f8>
ffffffffc0201508:	00003617          	auipc	a2,0x3
ffffffffc020150c:	37060613          	addi	a2,a2,880 # ffffffffc0204878 <commands+0x810>
ffffffffc0201510:	0ff00593          	li	a1,255
ffffffffc0201514:	00003517          	auipc	a0,0x3
ffffffffc0201518:	37c50513          	addi	a0,a0,892 # ffffffffc0204890 <commands+0x828>
ffffffffc020151c:	f3ffe0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(alloc_page() == NULL);
ffffffffc0201520:	00003697          	auipc	a3,0x3
ffffffffc0201524:	4e068693          	addi	a3,a3,1248 # ffffffffc0204a00 <commands+0x998>
ffffffffc0201528:	00003617          	auipc	a2,0x3
ffffffffc020152c:	35060613          	addi	a2,a2,848 # ffffffffc0204878 <commands+0x810>
ffffffffc0201530:	0fd00593          	li	a1,253
ffffffffc0201534:	00003517          	auipc	a0,0x3
ffffffffc0201538:	35c50513          	addi	a0,a0,860 # ffffffffc0204890 <commands+0x828>
ffffffffc020153c:	f1ffe0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((p = alloc_page()) == p0);
ffffffffc0201540:	00003697          	auipc	a3,0x3
ffffffffc0201544:	50068693          	addi	a3,a3,1280 # ffffffffc0204a40 <commands+0x9d8>
ffffffffc0201548:	00003617          	auipc	a2,0x3
ffffffffc020154c:	33060613          	addi	a2,a2,816 # ffffffffc0204878 <commands+0x810>
ffffffffc0201550:	0fc00593          	li	a1,252
ffffffffc0201554:	00003517          	auipc	a0,0x3
ffffffffc0201558:	33c50513          	addi	a0,a0,828 # ffffffffc0204890 <commands+0x828>
ffffffffc020155c:	efffe0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0201560 <best_fit_free_pages>:
best_fit_free_pages(struct Page *base, size_t n) {
ffffffffc0201560:	1141                	addi	sp,sp,-16
ffffffffc0201562:	e406                	sd	ra,8(sp)
    assert(n > 0);
ffffffffc0201564:	14058463          	beqz	a1,ffffffffc02016ac <best_fit_free_pages+0x14c>
    for (; p != base + n; p ++) {
ffffffffc0201568:	00659693          	slli	a3,a1,0x6
ffffffffc020156c:	96aa                	add	a3,a3,a0
ffffffffc020156e:	87aa                	mv	a5,a0
ffffffffc0201570:	02d50263          	beq	a0,a3,ffffffffc0201594 <best_fit_free_pages+0x34>
ffffffffc0201574:	6798                	ld	a4,8(a5)
        assert(!PageReserved(p) && !PageProperty(p));
ffffffffc0201576:	8b05                	andi	a4,a4,1
ffffffffc0201578:	10071a63          	bnez	a4,ffffffffc020168c <best_fit_free_pages+0x12c>
ffffffffc020157c:	6798                	ld	a4,8(a5)
ffffffffc020157e:	8b09                	andi	a4,a4,2
ffffffffc0201580:	10071663          	bnez	a4,ffffffffc020168c <best_fit_free_pages+0x12c>
        p->flags = 0;
ffffffffc0201584:	0007b423          	sd	zero,8(a5)
}

static inline void
set_page_ref(struct Page *page, int val)
{
    page->ref = val;
ffffffffc0201588:	0007a023          	sw	zero,0(a5)
    for (; p != base + n; p ++) {
ffffffffc020158c:	04078793          	addi	a5,a5,64
ffffffffc0201590:	fed792e3          	bne	a5,a3,ffffffffc0201574 <best_fit_free_pages+0x14>
    base->property = n;          // 首页记录块大小
ffffffffc0201594:	2581                	sext.w	a1,a1
ffffffffc0201596:	c90c                	sw	a1,16(a0)
    SetPageProperty(base);       // 标记为空闲块
ffffffffc0201598:	00850893          	addi	a7,a0,8
    __op_bit(or, __NOP, nr, ((volatile unsigned long *)addr));
ffffffffc020159c:	4789                	li	a5,2
ffffffffc020159e:	40f8b02f          	amoor.d	zero,a5,(a7)
    nr_free += n;                // 增加空闲页总数
ffffffffc02015a2:	00008697          	auipc	a3,0x8
ffffffffc02015a6:	e8e68693          	addi	a3,a3,-370 # ffffffffc0209430 <free_area>
ffffffffc02015aa:	4a98                	lw	a4,16(a3)
    return list->next == list;
ffffffffc02015ac:	669c                	ld	a5,8(a3)
        list_add(&free_list, &(base->page_link));
ffffffffc02015ae:	01850613          	addi	a2,a0,24
    nr_free += n;                // 增加空闲页总数
ffffffffc02015b2:	9db9                	addw	a1,a1,a4
ffffffffc02015b4:	ca8c                	sw	a1,16(a3)
    if (list_empty(&free_list)) {
ffffffffc02015b6:	0ad78463          	beq	a5,a3,ffffffffc020165e <best_fit_free_pages+0xfe>
            struct Page* page = le2page(le, page_link);
ffffffffc02015ba:	fe878713          	addi	a4,a5,-24
ffffffffc02015be:	0006b803          	ld	a6,0(a3)
    if (list_empty(&free_list)) {
ffffffffc02015c2:	4581                	li	a1,0
            if (base < page) {
ffffffffc02015c4:	00e56a63          	bltu	a0,a4,ffffffffc02015d8 <best_fit_free_pages+0x78>
    return listelm->next;
ffffffffc02015c8:	6798                	ld	a4,8(a5)
            } else if (list_next(le) == &free_list) {
ffffffffc02015ca:	04d70c63          	beq	a4,a3,ffffffffc0201622 <best_fit_free_pages+0xc2>
    for (; p != base + n; p ++) {
ffffffffc02015ce:	87ba                	mv	a5,a4
            struct Page* page = le2page(le, page_link);
ffffffffc02015d0:	fe878713          	addi	a4,a5,-24
            if (base < page) {
ffffffffc02015d4:	fee57ae3          	bgeu	a0,a4,ffffffffc02015c8 <best_fit_free_pages+0x68>
ffffffffc02015d8:	c199                	beqz	a1,ffffffffc02015de <best_fit_free_pages+0x7e>
ffffffffc02015da:	0106b023          	sd	a6,0(a3)
    __list_add(elm, listelm->prev, listelm);
ffffffffc02015de:	6398                	ld	a4,0(a5)
    prev->next = next->prev = elm;
ffffffffc02015e0:	e390                	sd	a2,0(a5)
ffffffffc02015e2:	e710                	sd	a2,8(a4)
    elm->next = next;
ffffffffc02015e4:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc02015e6:	ed18                	sd	a4,24(a0)
    if (le != &free_list) {
ffffffffc02015e8:	00d70d63          	beq	a4,a3,ffffffffc0201602 <best_fit_free_pages+0xa2>
        if (p + p->property == base) {  // 前块末尾与当前块起始连续
ffffffffc02015ec:	ff872583          	lw	a1,-8(a4)
        p = le2page(le, page_link);
ffffffffc02015f0:	fe870613          	addi	a2,a4,-24
        if (p + p->property == base) {  // 前块末尾与当前块起始连续
ffffffffc02015f4:	02059813          	slli	a6,a1,0x20
ffffffffc02015f8:	01a85793          	srli	a5,a6,0x1a
ffffffffc02015fc:	97b2                	add	a5,a5,a2
ffffffffc02015fe:	02f50c63          	beq	a0,a5,ffffffffc0201636 <best_fit_free_pages+0xd6>
    return listelm->next;
ffffffffc0201602:	711c                	ld	a5,32(a0)
    if (le != &free_list) {
ffffffffc0201604:	00d78c63          	beq	a5,a3,ffffffffc020161c <best_fit_free_pages+0xbc>
        if (base + base->property == p) {
ffffffffc0201608:	4910                	lw	a2,16(a0)
        p = le2page(le, page_link);
ffffffffc020160a:	fe878693          	addi	a3,a5,-24
        if (base + base->property == p) {
ffffffffc020160e:	02061593          	slli	a1,a2,0x20
ffffffffc0201612:	01a5d713          	srli	a4,a1,0x1a
ffffffffc0201616:	972a                	add	a4,a4,a0
ffffffffc0201618:	04e68a63          	beq	a3,a4,ffffffffc020166c <best_fit_free_pages+0x10c>
}
ffffffffc020161c:	60a2                	ld	ra,8(sp)
ffffffffc020161e:	0141                	addi	sp,sp,16
ffffffffc0201620:	8082                	ret
    prev->next = next->prev = elm;
ffffffffc0201622:	e790                	sd	a2,8(a5)
    elm->next = next;
ffffffffc0201624:	f114                	sd	a3,32(a0)
    return listelm->next;
ffffffffc0201626:	6798                	ld	a4,8(a5)
    elm->prev = prev;
ffffffffc0201628:	ed1c                	sd	a5,24(a0)
        while ((le = list_next(le)) != &free_list) {
ffffffffc020162a:	02d70763          	beq	a4,a3,ffffffffc0201658 <best_fit_free_pages+0xf8>
    prev->next = next->prev = elm;
ffffffffc020162e:	8832                	mv	a6,a2
ffffffffc0201630:	4585                	li	a1,1
    for (; p != base + n; p ++) {
ffffffffc0201632:	87ba                	mv	a5,a4
ffffffffc0201634:	bf71                	j	ffffffffc02015d0 <best_fit_free_pages+0x70>
            p->property += base->property;  // 合并大小
ffffffffc0201636:	491c                	lw	a5,16(a0)
ffffffffc0201638:	9dbd                	addw	a1,a1,a5
ffffffffc020163a:	feb72c23          	sw	a1,-8(a4)
    __op_bit(and, __NOT, nr, ((volatile unsigned long *)addr));
ffffffffc020163e:	57f5                	li	a5,-3
ffffffffc0201640:	60f8b02f          	amoand.d	zero,a5,(a7)
    __list_del(listelm->prev, listelm->next);
ffffffffc0201644:	01853803          	ld	a6,24(a0)
ffffffffc0201648:	710c                	ld	a1,32(a0)
            base = p;                       // 更新基准块为合并后的块
ffffffffc020164a:	8532                	mv	a0,a2
    prev->next = next;
ffffffffc020164c:	00b83423          	sd	a1,8(a6)
    return listelm->next;
ffffffffc0201650:	671c                	ld	a5,8(a4)
    next->prev = prev;
ffffffffc0201652:	0105b023          	sd	a6,0(a1)
ffffffffc0201656:	b77d                	j	ffffffffc0201604 <best_fit_free_pages+0xa4>
ffffffffc0201658:	e290                	sd	a2,0(a3)
        while ((le = list_next(le)) != &free_list) {
ffffffffc020165a:	873e                	mv	a4,a5
ffffffffc020165c:	bf41                	j	ffffffffc02015ec <best_fit_free_pages+0x8c>
}
ffffffffc020165e:	60a2                	ld	ra,8(sp)
    prev->next = next->prev = elm;
ffffffffc0201660:	e390                	sd	a2,0(a5)
ffffffffc0201662:	e790                	sd	a2,8(a5)
    elm->next = next;
ffffffffc0201664:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc0201666:	ed1c                	sd	a5,24(a0)
ffffffffc0201668:	0141                	addi	sp,sp,16
ffffffffc020166a:	8082                	ret
            base->property += p->property;
ffffffffc020166c:	ff87a703          	lw	a4,-8(a5)
ffffffffc0201670:	ff078693          	addi	a3,a5,-16
ffffffffc0201674:	9e39                	addw	a2,a2,a4
ffffffffc0201676:	c910                	sw	a2,16(a0)
ffffffffc0201678:	5775                	li	a4,-3
ffffffffc020167a:	60e6b02f          	amoand.d	zero,a4,(a3)
    __list_del(listelm->prev, listelm->next);
ffffffffc020167e:	6398                	ld	a4,0(a5)
ffffffffc0201680:	679c                	ld	a5,8(a5)
}
ffffffffc0201682:	60a2                	ld	ra,8(sp)
    prev->next = next;
ffffffffc0201684:	e71c                	sd	a5,8(a4)
    next->prev = prev;
ffffffffc0201686:	e398                	sd	a4,0(a5)
ffffffffc0201688:	0141                	addi	sp,sp,16
ffffffffc020168a:	8082                	ret
        assert(!PageReserved(p) && !PageProperty(p));
ffffffffc020168c:	00003697          	auipc	a3,0x3
ffffffffc0201690:	4dc68693          	addi	a3,a3,1244 # ffffffffc0204b68 <commands+0xb00>
ffffffffc0201694:	00003617          	auipc	a2,0x3
ffffffffc0201698:	1e460613          	addi	a2,a2,484 # ffffffffc0204878 <commands+0x810>
ffffffffc020169c:	09700593          	li	a1,151
ffffffffc02016a0:	00003517          	auipc	a0,0x3
ffffffffc02016a4:	1f050513          	addi	a0,a0,496 # ffffffffc0204890 <commands+0x828>
ffffffffc02016a8:	db3fe0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(n > 0);
ffffffffc02016ac:	00003697          	auipc	a3,0x3
ffffffffc02016b0:	1c468693          	addi	a3,a3,452 # ffffffffc0204870 <commands+0x808>
ffffffffc02016b4:	00003617          	auipc	a2,0x3
ffffffffc02016b8:	1c460613          	addi	a2,a2,452 # ffffffffc0204878 <commands+0x810>
ffffffffc02016bc:	09400593          	li	a1,148
ffffffffc02016c0:	00003517          	auipc	a0,0x3
ffffffffc02016c4:	1d050513          	addi	a0,a0,464 # ffffffffc0204890 <commands+0x828>
ffffffffc02016c8:	d93fe0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc02016cc <best_fit_init_memmap>:
best_fit_init_memmap(struct Page *base, size_t n) {
ffffffffc02016cc:	1141                	addi	sp,sp,-16
ffffffffc02016ce:	e406                	sd	ra,8(sp)
    assert(n > 0);
ffffffffc02016d0:	c5f1                	beqz	a1,ffffffffc020179c <best_fit_init_memmap+0xd0>
    for (; p != base + n; p ++) {
ffffffffc02016d2:	00659693          	slli	a3,a1,0x6
ffffffffc02016d6:	96aa                	add	a3,a3,a0
ffffffffc02016d8:	87aa                	mv	a5,a0
ffffffffc02016da:	00d50f63          	beq	a0,a3,ffffffffc02016f8 <best_fit_init_memmap+0x2c>
    return (((*(volatile unsigned long *)addr) >> nr) & 1);
ffffffffc02016de:	6798                	ld	a4,8(a5)
        assert(PageReserved(p));
ffffffffc02016e0:	8b05                	andi	a4,a4,1
ffffffffc02016e2:	cf49                	beqz	a4,ffffffffc020177c <best_fit_init_memmap+0xb0>
        p->flags = 0;          // 清除标志位（如PG_reserved）
ffffffffc02016e4:	0007b423          	sd	zero,8(a5)
        p->property = 0;       // 非首页的property设为0
ffffffffc02016e8:	0007a823          	sw	zero,16(a5)
ffffffffc02016ec:	0007a023          	sw	zero,0(a5)
    for (; p != base + n; p ++) {
ffffffffc02016f0:	04078793          	addi	a5,a5,64
ffffffffc02016f4:	fed795e3          	bne	a5,a3,ffffffffc02016de <best_fit_init_memmap+0x12>
    base->property = n;
ffffffffc02016f8:	2581                	sext.w	a1,a1
ffffffffc02016fa:	c90c                	sw	a1,16(a0)
    __op_bit(or, __NOP, nr, ((volatile unsigned long *)addr));
ffffffffc02016fc:	4789                	li	a5,2
ffffffffc02016fe:	00850713          	addi	a4,a0,8
ffffffffc0201702:	40f7302f          	amoor.d	zero,a5,(a4)
    nr_free += n;
ffffffffc0201706:	00008697          	auipc	a3,0x8
ffffffffc020170a:	d2a68693          	addi	a3,a3,-726 # ffffffffc0209430 <free_area>
ffffffffc020170e:	4a98                	lw	a4,16(a3)
    return list->next == list;
ffffffffc0201710:	669c                	ld	a5,8(a3)
        list_add(&free_list, &(base->page_link));
ffffffffc0201712:	01850613          	addi	a2,a0,24
    nr_free += n;
ffffffffc0201716:	9db9                	addw	a1,a1,a4
ffffffffc0201718:	ca8c                	sw	a1,16(a3)
    if (list_empty(&free_list)) {
ffffffffc020171a:	04d78a63          	beq	a5,a3,ffffffffc020176e <best_fit_init_memmap+0xa2>
            struct Page* page = le2page(le, page_link);
ffffffffc020171e:	fe878713          	addi	a4,a5,-24
ffffffffc0201722:	0006b803          	ld	a6,0(a3)
    if (list_empty(&free_list)) {
ffffffffc0201726:	4581                	li	a1,0
            if (base < page) {
ffffffffc0201728:	00e56a63          	bltu	a0,a4,ffffffffc020173c <best_fit_init_memmap+0x70>
    return listelm->next;
ffffffffc020172c:	6798                	ld	a4,8(a5)
            } else if (list_next(le) == &free_list) {
ffffffffc020172e:	02d70263          	beq	a4,a3,ffffffffc0201752 <best_fit_init_memmap+0x86>
    for (; p != base + n; p ++) {
ffffffffc0201732:	87ba                	mv	a5,a4
            struct Page* page = le2page(le, page_link);
ffffffffc0201734:	fe878713          	addi	a4,a5,-24
            if (base < page) {
ffffffffc0201738:	fee57ae3          	bgeu	a0,a4,ffffffffc020172c <best_fit_init_memmap+0x60>
ffffffffc020173c:	c199                	beqz	a1,ffffffffc0201742 <best_fit_init_memmap+0x76>
ffffffffc020173e:	0106b023          	sd	a6,0(a3)
    __list_add(elm, listelm->prev, listelm);
ffffffffc0201742:	6398                	ld	a4,0(a5)
}
ffffffffc0201744:	60a2                	ld	ra,8(sp)
    prev->next = next->prev = elm;
ffffffffc0201746:	e390                	sd	a2,0(a5)
ffffffffc0201748:	e710                	sd	a2,8(a4)
    elm->next = next;
ffffffffc020174a:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc020174c:	ed18                	sd	a4,24(a0)
ffffffffc020174e:	0141                	addi	sp,sp,16
ffffffffc0201750:	8082                	ret
    prev->next = next->prev = elm;
ffffffffc0201752:	e790                	sd	a2,8(a5)
    elm->next = next;
ffffffffc0201754:	f114                	sd	a3,32(a0)
    return listelm->next;
ffffffffc0201756:	6798                	ld	a4,8(a5)
    elm->prev = prev;
ffffffffc0201758:	ed1c                	sd	a5,24(a0)
        while ((le = list_next(le)) != &free_list) {
ffffffffc020175a:	00d70663          	beq	a4,a3,ffffffffc0201766 <best_fit_init_memmap+0x9a>
    prev->next = next->prev = elm;
ffffffffc020175e:	8832                	mv	a6,a2
ffffffffc0201760:	4585                	li	a1,1
    for (; p != base + n; p ++) {
ffffffffc0201762:	87ba                	mv	a5,a4
ffffffffc0201764:	bfc1                	j	ffffffffc0201734 <best_fit_init_memmap+0x68>
}
ffffffffc0201766:	60a2                	ld	ra,8(sp)
ffffffffc0201768:	e290                	sd	a2,0(a3)
ffffffffc020176a:	0141                	addi	sp,sp,16
ffffffffc020176c:	8082                	ret
ffffffffc020176e:	60a2                	ld	ra,8(sp)
ffffffffc0201770:	e390                	sd	a2,0(a5)
ffffffffc0201772:	e790                	sd	a2,8(a5)
    elm->next = next;
ffffffffc0201774:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc0201776:	ed1c                	sd	a5,24(a0)
ffffffffc0201778:	0141                	addi	sp,sp,16
ffffffffc020177a:	8082                	ret
        assert(PageReserved(p));
ffffffffc020177c:	00003697          	auipc	a3,0x3
ffffffffc0201780:	41468693          	addi	a3,a3,1044 # ffffffffc0204b90 <commands+0xb28>
ffffffffc0201784:	00003617          	auipc	a2,0x3
ffffffffc0201788:	0f460613          	addi	a2,a2,244 # ffffffffc0204878 <commands+0x810>
ffffffffc020178c:	04a00593          	li	a1,74
ffffffffc0201790:	00003517          	auipc	a0,0x3
ffffffffc0201794:	10050513          	addi	a0,a0,256 # ffffffffc0204890 <commands+0x828>
ffffffffc0201798:	cc3fe0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(n > 0);
ffffffffc020179c:	00003697          	auipc	a3,0x3
ffffffffc02017a0:	0d468693          	addi	a3,a3,212 # ffffffffc0204870 <commands+0x808>
ffffffffc02017a4:	00003617          	auipc	a2,0x3
ffffffffc02017a8:	0d460613          	addi	a2,a2,212 # ffffffffc0204878 <commands+0x810>
ffffffffc02017ac:	04700593          	li	a1,71
ffffffffc02017b0:	00003517          	auipc	a0,0x3
ffffffffc02017b4:	0e050513          	addi	a0,a0,224 # ffffffffc0204890 <commands+0x828>
ffffffffc02017b8:	ca3fe0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc02017bc <slob_free>:
static void slob_free(void *block, int size)
{
	slob_t *cur, *b = (slob_t *)block;
	unsigned long flags;

	if (!block)
ffffffffc02017bc:	c94d                	beqz	a0,ffffffffc020186e <slob_free+0xb2>
{
ffffffffc02017be:	1141                	addi	sp,sp,-16
ffffffffc02017c0:	e022                	sd	s0,0(sp)
ffffffffc02017c2:	e406                	sd	ra,8(sp)
ffffffffc02017c4:	842a                	mv	s0,a0
		return;

	if (size)
ffffffffc02017c6:	e9c1                	bnez	a1,ffffffffc0201856 <slob_free+0x9a>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc02017c8:	100027f3          	csrr	a5,sstatus
ffffffffc02017cc:	8b89                	andi	a5,a5,2
    return 0;
ffffffffc02017ce:	4501                	li	a0,0
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc02017d0:	ebd9                	bnez	a5,ffffffffc0201866 <slob_free+0xaa>
		b->units = SLOB_UNITS(size);

	/* Find reinsertion point */
	spin_lock_irqsave(&slob_lock, flags);
	for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next)
ffffffffc02017d2:	00008617          	auipc	a2,0x8
ffffffffc02017d6:	84e60613          	addi	a2,a2,-1970 # ffffffffc0209020 <slobfree>
ffffffffc02017da:	621c                	ld	a5,0(a2)
		if (cur >= cur->next && (b > cur || b < cur->next))
ffffffffc02017dc:	873e                	mv	a4,a5
	for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next)
ffffffffc02017de:	679c                	ld	a5,8(a5)
ffffffffc02017e0:	02877a63          	bgeu	a4,s0,ffffffffc0201814 <slob_free+0x58>
ffffffffc02017e4:	00f46463          	bltu	s0,a5,ffffffffc02017ec <slob_free+0x30>
		if (cur >= cur->next && (b > cur || b < cur->next))
ffffffffc02017e8:	fef76ae3          	bltu	a4,a5,ffffffffc02017dc <slob_free+0x20>
			break;

	if (b + b->units == cur->next)
ffffffffc02017ec:	400c                	lw	a1,0(s0)
ffffffffc02017ee:	00459693          	slli	a3,a1,0x4
ffffffffc02017f2:	96a2                	add	a3,a3,s0
ffffffffc02017f4:	02d78a63          	beq	a5,a3,ffffffffc0201828 <slob_free+0x6c>
		b->next = cur->next->next;
	}
	else
		b->next = cur->next;

	if (cur + cur->units == b)
ffffffffc02017f8:	4314                	lw	a3,0(a4)
		b->next = cur->next;
ffffffffc02017fa:	e41c                	sd	a5,8(s0)
	if (cur + cur->units == b)
ffffffffc02017fc:	00469793          	slli	a5,a3,0x4
ffffffffc0201800:	97ba                	add	a5,a5,a4
ffffffffc0201802:	02f40e63          	beq	s0,a5,ffffffffc020183e <slob_free+0x82>
	{
		cur->units += b->units;
		cur->next = b->next;
	}
	else
		cur->next = b;
ffffffffc0201806:	e700                	sd	s0,8(a4)

	slobfree = cur;
ffffffffc0201808:	e218                	sd	a4,0(a2)
    if (flag) {
ffffffffc020180a:	e129                	bnez	a0,ffffffffc020184c <slob_free+0x90>

	spin_unlock_irqrestore(&slob_lock, flags);
}
ffffffffc020180c:	60a2                	ld	ra,8(sp)
ffffffffc020180e:	6402                	ld	s0,0(sp)
ffffffffc0201810:	0141                	addi	sp,sp,16
ffffffffc0201812:	8082                	ret
		if (cur >= cur->next && (b > cur || b < cur->next))
ffffffffc0201814:	fcf764e3          	bltu	a4,a5,ffffffffc02017dc <slob_free+0x20>
ffffffffc0201818:	fcf472e3          	bgeu	s0,a5,ffffffffc02017dc <slob_free+0x20>
	if (b + b->units == cur->next)
ffffffffc020181c:	400c                	lw	a1,0(s0)
ffffffffc020181e:	00459693          	slli	a3,a1,0x4
ffffffffc0201822:	96a2                	add	a3,a3,s0
ffffffffc0201824:	fcd79ae3          	bne	a5,a3,ffffffffc02017f8 <slob_free+0x3c>
		b->units += cur->next->units;
ffffffffc0201828:	4394                	lw	a3,0(a5)
		b->next = cur->next->next;
ffffffffc020182a:	679c                	ld	a5,8(a5)
		b->units += cur->next->units;
ffffffffc020182c:	9db5                	addw	a1,a1,a3
ffffffffc020182e:	c00c                	sw	a1,0(s0)
	if (cur + cur->units == b)
ffffffffc0201830:	4314                	lw	a3,0(a4)
		b->next = cur->next->next;
ffffffffc0201832:	e41c                	sd	a5,8(s0)
	if (cur + cur->units == b)
ffffffffc0201834:	00469793          	slli	a5,a3,0x4
ffffffffc0201838:	97ba                	add	a5,a5,a4
ffffffffc020183a:	fcf416e3          	bne	s0,a5,ffffffffc0201806 <slob_free+0x4a>
		cur->units += b->units;
ffffffffc020183e:	401c                	lw	a5,0(s0)
		cur->next = b->next;
ffffffffc0201840:	640c                	ld	a1,8(s0)
	slobfree = cur;
ffffffffc0201842:	e218                	sd	a4,0(a2)
		cur->units += b->units;
ffffffffc0201844:	9ebd                	addw	a3,a3,a5
ffffffffc0201846:	c314                	sw	a3,0(a4)
		cur->next = b->next;
ffffffffc0201848:	e70c                	sd	a1,8(a4)
ffffffffc020184a:	d169                	beqz	a0,ffffffffc020180c <slob_free+0x50>
}
ffffffffc020184c:	6402                	ld	s0,0(sp)
ffffffffc020184e:	60a2                	ld	ra,8(sp)
ffffffffc0201850:	0141                	addi	sp,sp,16
        intr_enable();
ffffffffc0201852:	8d8ff06f          	j	ffffffffc020092a <intr_enable>
		b->units = SLOB_UNITS(size);
ffffffffc0201856:	25bd                	addiw	a1,a1,15
ffffffffc0201858:	8191                	srli	a1,a1,0x4
ffffffffc020185a:	c10c                	sw	a1,0(a0)
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc020185c:	100027f3          	csrr	a5,sstatus
ffffffffc0201860:	8b89                	andi	a5,a5,2
    return 0;
ffffffffc0201862:	4501                	li	a0,0
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0201864:	d7bd                	beqz	a5,ffffffffc02017d2 <slob_free+0x16>
        intr_disable();
ffffffffc0201866:	8caff0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        return 1;
ffffffffc020186a:	4505                	li	a0,1
ffffffffc020186c:	b79d                	j	ffffffffc02017d2 <slob_free+0x16>
ffffffffc020186e:	8082                	ret

ffffffffc0201870 <__slob_get_free_pages.constprop.0>:
	struct Page *page = alloc_pages(1 << order);
ffffffffc0201870:	4785                	li	a5,1
static void *__slob_get_free_pages(gfp_t gfp, int order)
ffffffffc0201872:	1141                	addi	sp,sp,-16
	struct Page *page = alloc_pages(1 << order);
ffffffffc0201874:	00a7953b          	sllw	a0,a5,a0
static void *__slob_get_free_pages(gfp_t gfp, int order)
ffffffffc0201878:	e406                	sd	ra,8(sp)
	struct Page *page = alloc_pages(1 << order);
ffffffffc020187a:	34e000ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
	if (!page)
ffffffffc020187e:	c91d                	beqz	a0,ffffffffc02018b4 <__slob_get_free_pages.constprop.0+0x44>
    return page - pages + nbase;
ffffffffc0201880:	0000c697          	auipc	a3,0xc
ffffffffc0201884:	c386b683          	ld	a3,-968(a3) # ffffffffc020d4b8 <pages>
ffffffffc0201888:	8d15                	sub	a0,a0,a3
ffffffffc020188a:	8519                	srai	a0,a0,0x6
ffffffffc020188c:	00004697          	auipc	a3,0x4
ffffffffc0201890:	0446b683          	ld	a3,68(a3) # ffffffffc02058d0 <nbase>
ffffffffc0201894:	9536                	add	a0,a0,a3
    return KADDR(page2pa(page));
ffffffffc0201896:	00c51793          	slli	a5,a0,0xc
ffffffffc020189a:	83b1                	srli	a5,a5,0xc
ffffffffc020189c:	0000c717          	auipc	a4,0xc
ffffffffc02018a0:	c1473703          	ld	a4,-1004(a4) # ffffffffc020d4b0 <npage>
    return page2ppn(page) << PGSHIFT;
ffffffffc02018a4:	0532                	slli	a0,a0,0xc
    return KADDR(page2pa(page));
ffffffffc02018a6:	00e7fa63          	bgeu	a5,a4,ffffffffc02018ba <__slob_get_free_pages.constprop.0+0x4a>
ffffffffc02018aa:	0000c697          	auipc	a3,0xc
ffffffffc02018ae:	c1e6b683          	ld	a3,-994(a3) # ffffffffc020d4c8 <va_pa_offset>
ffffffffc02018b2:	9536                	add	a0,a0,a3
}
ffffffffc02018b4:	60a2                	ld	ra,8(sp)
ffffffffc02018b6:	0141                	addi	sp,sp,16
ffffffffc02018b8:	8082                	ret
ffffffffc02018ba:	86aa                	mv	a3,a0
ffffffffc02018bc:	00003617          	auipc	a2,0x3
ffffffffc02018c0:	33460613          	addi	a2,a2,820 # ffffffffc0204bf0 <best_fit_pmm_manager+0x38>
ffffffffc02018c4:	07100593          	li	a1,113
ffffffffc02018c8:	00003517          	auipc	a0,0x3
ffffffffc02018cc:	35050513          	addi	a0,a0,848 # ffffffffc0204c18 <best_fit_pmm_manager+0x60>
ffffffffc02018d0:	b8bfe0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc02018d4 <slob_alloc.constprop.0>:
static void *slob_alloc(size_t size, gfp_t gfp, int align)
ffffffffc02018d4:	1101                	addi	sp,sp,-32
ffffffffc02018d6:	ec06                	sd	ra,24(sp)
ffffffffc02018d8:	e822                	sd	s0,16(sp)
ffffffffc02018da:	e426                	sd	s1,8(sp)
ffffffffc02018dc:	e04a                	sd	s2,0(sp)
	assert((size + SLOB_UNIT) < PAGE_SIZE);
ffffffffc02018de:	01050713          	addi	a4,a0,16
ffffffffc02018e2:	6785                	lui	a5,0x1
ffffffffc02018e4:	0cf77363          	bgeu	a4,a5,ffffffffc02019aa <slob_alloc.constprop.0+0xd6>
	int delta = 0, units = SLOB_UNITS(size);
ffffffffc02018e8:	00f50493          	addi	s1,a0,15
ffffffffc02018ec:	8091                	srli	s1,s1,0x4
ffffffffc02018ee:	2481                	sext.w	s1,s1
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc02018f0:	10002673          	csrr	a2,sstatus
ffffffffc02018f4:	8a09                	andi	a2,a2,2
ffffffffc02018f6:	e25d                	bnez	a2,ffffffffc020199c <slob_alloc.constprop.0+0xc8>
	prev = slobfree;
ffffffffc02018f8:	00007917          	auipc	s2,0x7
ffffffffc02018fc:	72890913          	addi	s2,s2,1832 # ffffffffc0209020 <slobfree>
ffffffffc0201900:	00093683          	ld	a3,0(s2)
	for (cur = prev->next;; prev = cur, cur = cur->next)
ffffffffc0201904:	669c                	ld	a5,8(a3)
		if (cur->units >= units + delta)
ffffffffc0201906:	4398                	lw	a4,0(a5)
ffffffffc0201908:	08975e63          	bge	a4,s1,ffffffffc02019a4 <slob_alloc.constprop.0+0xd0>
		if (cur == slobfree)
ffffffffc020190c:	00d78b63          	beq	a5,a3,ffffffffc0201922 <slob_alloc.constprop.0+0x4e>
	for (cur = prev->next;; prev = cur, cur = cur->next)
ffffffffc0201910:	6780                	ld	s0,8(a5)
		if (cur->units >= units + delta)
ffffffffc0201912:	4018                	lw	a4,0(s0)
ffffffffc0201914:	02975a63          	bge	a4,s1,ffffffffc0201948 <slob_alloc.constprop.0+0x74>
		if (cur == slobfree)
ffffffffc0201918:	00093683          	ld	a3,0(s2)
ffffffffc020191c:	87a2                	mv	a5,s0
ffffffffc020191e:	fed799e3          	bne	a5,a3,ffffffffc0201910 <slob_alloc.constprop.0+0x3c>
    if (flag) {
ffffffffc0201922:	ee31                	bnez	a2,ffffffffc020197e <slob_alloc.constprop.0+0xaa>
			cur = (slob_t *)__slob_get_free_page(gfp);
ffffffffc0201924:	4501                	li	a0,0
ffffffffc0201926:	f4bff0ef          	jal	ra,ffffffffc0201870 <__slob_get_free_pages.constprop.0>
ffffffffc020192a:	842a                	mv	s0,a0
			if (!cur)
ffffffffc020192c:	cd05                	beqz	a0,ffffffffc0201964 <slob_alloc.constprop.0+0x90>
			slob_free(cur, PAGE_SIZE);
ffffffffc020192e:	6585                	lui	a1,0x1
ffffffffc0201930:	e8dff0ef          	jal	ra,ffffffffc02017bc <slob_free>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0201934:	10002673          	csrr	a2,sstatus
ffffffffc0201938:	8a09                	andi	a2,a2,2
ffffffffc020193a:	ee05                	bnez	a2,ffffffffc0201972 <slob_alloc.constprop.0+0x9e>
			cur = slobfree;
ffffffffc020193c:	00093783          	ld	a5,0(s2)
	for (cur = prev->next;; prev = cur, cur = cur->next)
ffffffffc0201940:	6780                	ld	s0,8(a5)
		if (cur->units >= units + delta)
ffffffffc0201942:	4018                	lw	a4,0(s0)
ffffffffc0201944:	fc974ae3          	blt	a4,s1,ffffffffc0201918 <slob_alloc.constprop.0+0x44>
			if (cur->units == units)	/* exact fit? */
ffffffffc0201948:	04e48763          	beq	s1,a4,ffffffffc0201996 <slob_alloc.constprop.0+0xc2>
				prev->next = cur + units;
ffffffffc020194c:	00449693          	slli	a3,s1,0x4
ffffffffc0201950:	96a2                	add	a3,a3,s0
ffffffffc0201952:	e794                	sd	a3,8(a5)
				prev->next->next = cur->next;
ffffffffc0201954:	640c                	ld	a1,8(s0)
				prev->next->units = cur->units - units;
ffffffffc0201956:	9f05                	subw	a4,a4,s1
ffffffffc0201958:	c298                	sw	a4,0(a3)
				prev->next->next = cur->next;
ffffffffc020195a:	e68c                	sd	a1,8(a3)
				cur->units = units;
ffffffffc020195c:	c004                	sw	s1,0(s0)
			slobfree = prev;
ffffffffc020195e:	00f93023          	sd	a5,0(s2)
    if (flag) {
ffffffffc0201962:	e20d                	bnez	a2,ffffffffc0201984 <slob_alloc.constprop.0+0xb0>
}
ffffffffc0201964:	60e2                	ld	ra,24(sp)
ffffffffc0201966:	8522                	mv	a0,s0
ffffffffc0201968:	6442                	ld	s0,16(sp)
ffffffffc020196a:	64a2                	ld	s1,8(sp)
ffffffffc020196c:	6902                	ld	s2,0(sp)
ffffffffc020196e:	6105                	addi	sp,sp,32
ffffffffc0201970:	8082                	ret
        intr_disable();
ffffffffc0201972:	fbffe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
			cur = slobfree;
ffffffffc0201976:	00093783          	ld	a5,0(s2)
        return 1;
ffffffffc020197a:	4605                	li	a2,1
ffffffffc020197c:	b7d1                	j	ffffffffc0201940 <slob_alloc.constprop.0+0x6c>
        intr_enable();
ffffffffc020197e:	fadfe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0201982:	b74d                	j	ffffffffc0201924 <slob_alloc.constprop.0+0x50>
ffffffffc0201984:	fa7fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
}
ffffffffc0201988:	60e2                	ld	ra,24(sp)
ffffffffc020198a:	8522                	mv	a0,s0
ffffffffc020198c:	6442                	ld	s0,16(sp)
ffffffffc020198e:	64a2                	ld	s1,8(sp)
ffffffffc0201990:	6902                	ld	s2,0(sp)
ffffffffc0201992:	6105                	addi	sp,sp,32
ffffffffc0201994:	8082                	ret
				prev->next = cur->next; /* unlink */
ffffffffc0201996:	6418                	ld	a4,8(s0)
ffffffffc0201998:	e798                	sd	a4,8(a5)
ffffffffc020199a:	b7d1                	j	ffffffffc020195e <slob_alloc.constprop.0+0x8a>
        intr_disable();
ffffffffc020199c:	f95fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        return 1;
ffffffffc02019a0:	4605                	li	a2,1
ffffffffc02019a2:	bf99                	j	ffffffffc02018f8 <slob_alloc.constprop.0+0x24>
		if (cur->units >= units + delta)
ffffffffc02019a4:	843e                	mv	s0,a5
ffffffffc02019a6:	87b6                	mv	a5,a3
ffffffffc02019a8:	b745                	j	ffffffffc0201948 <slob_alloc.constprop.0+0x74>
	assert((size + SLOB_UNIT) < PAGE_SIZE);
ffffffffc02019aa:	00003697          	auipc	a3,0x3
ffffffffc02019ae:	27e68693          	addi	a3,a3,638 # ffffffffc0204c28 <best_fit_pmm_manager+0x70>
ffffffffc02019b2:	00003617          	auipc	a2,0x3
ffffffffc02019b6:	ec660613          	addi	a2,a2,-314 # ffffffffc0204878 <commands+0x810>
ffffffffc02019ba:	06300593          	li	a1,99
ffffffffc02019be:	00003517          	auipc	a0,0x3
ffffffffc02019c2:	28a50513          	addi	a0,a0,650 # ffffffffc0204c48 <best_fit_pmm_manager+0x90>
ffffffffc02019c6:	a95fe0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc02019ca <kmalloc_init>:
	cprintf("use SLOB allocator\n");
}

inline void
kmalloc_init(void)
{
ffffffffc02019ca:	1141                	addi	sp,sp,-16
	cprintf("use SLOB allocator\n");
ffffffffc02019cc:	00003517          	auipc	a0,0x3
ffffffffc02019d0:	29450513          	addi	a0,a0,660 # ffffffffc0204c60 <best_fit_pmm_manager+0xa8>
{
ffffffffc02019d4:	e406                	sd	ra,8(sp)
	cprintf("use SLOB allocator\n");
ffffffffc02019d6:	fbefe0ef          	jal	ra,ffffffffc0200194 <cprintf>
	slob_init();
	cprintf("kmalloc_init() succeeded!\n");
}
ffffffffc02019da:	60a2                	ld	ra,8(sp)
	cprintf("kmalloc_init() succeeded!\n");
ffffffffc02019dc:	00003517          	auipc	a0,0x3
ffffffffc02019e0:	29c50513          	addi	a0,a0,668 # ffffffffc0204c78 <best_fit_pmm_manager+0xc0>
}
ffffffffc02019e4:	0141                	addi	sp,sp,16
	cprintf("kmalloc_init() succeeded!\n");
ffffffffc02019e6:	faefe06f          	j	ffffffffc0200194 <cprintf>

ffffffffc02019ea <kmalloc>:
	return 0;
}

void *
kmalloc(size_t size)
{
ffffffffc02019ea:	1101                	addi	sp,sp,-32
ffffffffc02019ec:	e04a                	sd	s2,0(sp)
	if (size < PAGE_SIZE - SLOB_UNIT)
ffffffffc02019ee:	6905                	lui	s2,0x1
{
ffffffffc02019f0:	e822                	sd	s0,16(sp)
ffffffffc02019f2:	ec06                	sd	ra,24(sp)
ffffffffc02019f4:	e426                	sd	s1,8(sp)
	if (size < PAGE_SIZE - SLOB_UNIT)
ffffffffc02019f6:	fef90793          	addi	a5,s2,-17 # fef <kern_entry-0xffffffffc01ff011>
{
ffffffffc02019fa:	842a                	mv	s0,a0
	if (size < PAGE_SIZE - SLOB_UNIT)
ffffffffc02019fc:	04a7f963          	bgeu	a5,a0,ffffffffc0201a4e <kmalloc+0x64>
	bb = slob_alloc(sizeof(bigblock_t), gfp, 0);
ffffffffc0201a00:	4561                	li	a0,24
ffffffffc0201a02:	ed3ff0ef          	jal	ra,ffffffffc02018d4 <slob_alloc.constprop.0>
ffffffffc0201a06:	84aa                	mv	s1,a0
	if (!bb)
ffffffffc0201a08:	c929                	beqz	a0,ffffffffc0201a5a <kmalloc+0x70>
	bb->order = find_order(size);
ffffffffc0201a0a:	0004079b          	sext.w	a5,s0
	int order = 0;
ffffffffc0201a0e:	4501                	li	a0,0
	for (; size > 4096; size >>= 1)
ffffffffc0201a10:	00f95763          	bge	s2,a5,ffffffffc0201a1e <kmalloc+0x34>
ffffffffc0201a14:	6705                	lui	a4,0x1
ffffffffc0201a16:	8785                	srai	a5,a5,0x1
		order++;
ffffffffc0201a18:	2505                	addiw	a0,a0,1
	for (; size > 4096; size >>= 1)
ffffffffc0201a1a:	fef74ee3          	blt	a4,a5,ffffffffc0201a16 <kmalloc+0x2c>
	bb->order = find_order(size);
ffffffffc0201a1e:	c088                	sw	a0,0(s1)
	bb->pages = (void *)__slob_get_free_pages(gfp, bb->order);
ffffffffc0201a20:	e51ff0ef          	jal	ra,ffffffffc0201870 <__slob_get_free_pages.constprop.0>
ffffffffc0201a24:	e488                	sd	a0,8(s1)
ffffffffc0201a26:	842a                	mv	s0,a0
	if (bb->pages)
ffffffffc0201a28:	c525                	beqz	a0,ffffffffc0201a90 <kmalloc+0xa6>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0201a2a:	100027f3          	csrr	a5,sstatus
ffffffffc0201a2e:	8b89                	andi	a5,a5,2
ffffffffc0201a30:	ef8d                	bnez	a5,ffffffffc0201a6a <kmalloc+0x80>
		bb->next = bigblocks;
ffffffffc0201a32:	0000c797          	auipc	a5,0xc
ffffffffc0201a36:	a6678793          	addi	a5,a5,-1434 # ffffffffc020d498 <bigblocks>
ffffffffc0201a3a:	6398                	ld	a4,0(a5)
		bigblocks = bb;
ffffffffc0201a3c:	e384                	sd	s1,0(a5)
		bb->next = bigblocks;
ffffffffc0201a3e:	e898                	sd	a4,16(s1)
	return __kmalloc(size, 0);
}
ffffffffc0201a40:	60e2                	ld	ra,24(sp)
ffffffffc0201a42:	8522                	mv	a0,s0
ffffffffc0201a44:	6442                	ld	s0,16(sp)
ffffffffc0201a46:	64a2                	ld	s1,8(sp)
ffffffffc0201a48:	6902                	ld	s2,0(sp)
ffffffffc0201a4a:	6105                	addi	sp,sp,32
ffffffffc0201a4c:	8082                	ret
		m = slob_alloc(size + SLOB_UNIT, gfp, 0);
ffffffffc0201a4e:	0541                	addi	a0,a0,16
ffffffffc0201a50:	e85ff0ef          	jal	ra,ffffffffc02018d4 <slob_alloc.constprop.0>
		return m ? (void *)(m + 1) : 0;
ffffffffc0201a54:	01050413          	addi	s0,a0,16
ffffffffc0201a58:	f565                	bnez	a0,ffffffffc0201a40 <kmalloc+0x56>
ffffffffc0201a5a:	4401                	li	s0,0
}
ffffffffc0201a5c:	60e2                	ld	ra,24(sp)
ffffffffc0201a5e:	8522                	mv	a0,s0
ffffffffc0201a60:	6442                	ld	s0,16(sp)
ffffffffc0201a62:	64a2                	ld	s1,8(sp)
ffffffffc0201a64:	6902                	ld	s2,0(sp)
ffffffffc0201a66:	6105                	addi	sp,sp,32
ffffffffc0201a68:	8082                	ret
        intr_disable();
ffffffffc0201a6a:	ec7fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
		bb->next = bigblocks;
ffffffffc0201a6e:	0000c797          	auipc	a5,0xc
ffffffffc0201a72:	a2a78793          	addi	a5,a5,-1494 # ffffffffc020d498 <bigblocks>
ffffffffc0201a76:	6398                	ld	a4,0(a5)
		bigblocks = bb;
ffffffffc0201a78:	e384                	sd	s1,0(a5)
		bb->next = bigblocks;
ffffffffc0201a7a:	e898                	sd	a4,16(s1)
        intr_enable();
ffffffffc0201a7c:	eaffe0ef          	jal	ra,ffffffffc020092a <intr_enable>
		return bb->pages;
ffffffffc0201a80:	6480                	ld	s0,8(s1)
}
ffffffffc0201a82:	60e2                	ld	ra,24(sp)
ffffffffc0201a84:	64a2                	ld	s1,8(sp)
ffffffffc0201a86:	8522                	mv	a0,s0
ffffffffc0201a88:	6442                	ld	s0,16(sp)
ffffffffc0201a8a:	6902                	ld	s2,0(sp)
ffffffffc0201a8c:	6105                	addi	sp,sp,32
ffffffffc0201a8e:	8082                	ret
	slob_free(bb, sizeof(bigblock_t));
ffffffffc0201a90:	45e1                	li	a1,24
ffffffffc0201a92:	8526                	mv	a0,s1
ffffffffc0201a94:	d29ff0ef          	jal	ra,ffffffffc02017bc <slob_free>
	return __kmalloc(size, 0);
ffffffffc0201a98:	b765                	j	ffffffffc0201a40 <kmalloc+0x56>

ffffffffc0201a9a <kfree>:
void kfree(void *block)
{
	bigblock_t *bb, **last = &bigblocks;
	unsigned long flags;

	if (!block)
ffffffffc0201a9a:	c169                	beqz	a0,ffffffffc0201b5c <kfree+0xc2>
{
ffffffffc0201a9c:	1101                	addi	sp,sp,-32
ffffffffc0201a9e:	e822                	sd	s0,16(sp)
ffffffffc0201aa0:	ec06                	sd	ra,24(sp)
ffffffffc0201aa2:	e426                	sd	s1,8(sp)
		return;

	if (!((unsigned long)block & (PAGE_SIZE - 1)))
ffffffffc0201aa4:	03451793          	slli	a5,a0,0x34
ffffffffc0201aa8:	842a                	mv	s0,a0
ffffffffc0201aaa:	e3d9                	bnez	a5,ffffffffc0201b30 <kfree+0x96>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0201aac:	100027f3          	csrr	a5,sstatus
ffffffffc0201ab0:	8b89                	andi	a5,a5,2
ffffffffc0201ab2:	e7d9                	bnez	a5,ffffffffc0201b40 <kfree+0xa6>
	{
		/* might be on the big block list */
		spin_lock_irqsave(&block_lock, flags);
		for (bb = bigblocks; bb; last = &bb->next, bb = bb->next)
ffffffffc0201ab4:	0000c797          	auipc	a5,0xc
ffffffffc0201ab8:	9e47b783          	ld	a5,-1564(a5) # ffffffffc020d498 <bigblocks>
    return 0;
ffffffffc0201abc:	4601                	li	a2,0
ffffffffc0201abe:	cbad                	beqz	a5,ffffffffc0201b30 <kfree+0x96>
	bigblock_t *bb, **last = &bigblocks;
ffffffffc0201ac0:	0000c697          	auipc	a3,0xc
ffffffffc0201ac4:	9d868693          	addi	a3,a3,-1576 # ffffffffc020d498 <bigblocks>
ffffffffc0201ac8:	a021                	j	ffffffffc0201ad0 <kfree+0x36>
		for (bb = bigblocks; bb; last = &bb->next, bb = bb->next)
ffffffffc0201aca:	01048693          	addi	a3,s1,16
ffffffffc0201ace:	c3a5                	beqz	a5,ffffffffc0201b2e <kfree+0x94>
		{
			if (bb->pages == block)
ffffffffc0201ad0:	6798                	ld	a4,8(a5)
ffffffffc0201ad2:	84be                	mv	s1,a5
			{
				*last = bb->next;
ffffffffc0201ad4:	6b9c                	ld	a5,16(a5)
			if (bb->pages == block)
ffffffffc0201ad6:	fe871ae3          	bne	a4,s0,ffffffffc0201aca <kfree+0x30>
				*last = bb->next;
ffffffffc0201ada:	e29c                	sd	a5,0(a3)
    if (flag) {
ffffffffc0201adc:	ee2d                	bnez	a2,ffffffffc0201b56 <kfree+0xbc>
    return pa2page(PADDR(kva));
ffffffffc0201ade:	c02007b7          	lui	a5,0xc0200
				spin_unlock_irqrestore(&block_lock, flags);
				__slob_free_pages((unsigned long)block, bb->order);
ffffffffc0201ae2:	4098                	lw	a4,0(s1)
ffffffffc0201ae4:	08f46963          	bltu	s0,a5,ffffffffc0201b76 <kfree+0xdc>
ffffffffc0201ae8:	0000c697          	auipc	a3,0xc
ffffffffc0201aec:	9e06b683          	ld	a3,-1568(a3) # ffffffffc020d4c8 <va_pa_offset>
ffffffffc0201af0:	8c15                	sub	s0,s0,a3
    if (PPN(pa) >= npage)
ffffffffc0201af2:	8031                	srli	s0,s0,0xc
ffffffffc0201af4:	0000c797          	auipc	a5,0xc
ffffffffc0201af8:	9bc7b783          	ld	a5,-1604(a5) # ffffffffc020d4b0 <npage>
ffffffffc0201afc:	06f47163          	bgeu	s0,a5,ffffffffc0201b5e <kfree+0xc4>
    return &pages[PPN(pa) - nbase];
ffffffffc0201b00:	00004517          	auipc	a0,0x4
ffffffffc0201b04:	dd053503          	ld	a0,-560(a0) # ffffffffc02058d0 <nbase>
ffffffffc0201b08:	8c09                	sub	s0,s0,a0
ffffffffc0201b0a:	041a                	slli	s0,s0,0x6
	free_pages(kva2page(kva), 1 << order);
ffffffffc0201b0c:	0000c517          	auipc	a0,0xc
ffffffffc0201b10:	9ac53503          	ld	a0,-1620(a0) # ffffffffc020d4b8 <pages>
ffffffffc0201b14:	4585                	li	a1,1
ffffffffc0201b16:	9522                	add	a0,a0,s0
ffffffffc0201b18:	00e595bb          	sllw	a1,a1,a4
ffffffffc0201b1c:	0ea000ef          	jal	ra,ffffffffc0201c06 <free_pages>
		spin_unlock_irqrestore(&block_lock, flags);
	}

	slob_free((slob_t *)block - 1, 0);
	return;
}
ffffffffc0201b20:	6442                	ld	s0,16(sp)
ffffffffc0201b22:	60e2                	ld	ra,24(sp)
				slob_free(bb, sizeof(bigblock_t));
ffffffffc0201b24:	8526                	mv	a0,s1
}
ffffffffc0201b26:	64a2                	ld	s1,8(sp)
				slob_free(bb, sizeof(bigblock_t));
ffffffffc0201b28:	45e1                	li	a1,24
}
ffffffffc0201b2a:	6105                	addi	sp,sp,32
	slob_free((slob_t *)block - 1, 0);
ffffffffc0201b2c:	b941                	j	ffffffffc02017bc <slob_free>
ffffffffc0201b2e:	e20d                	bnez	a2,ffffffffc0201b50 <kfree+0xb6>
ffffffffc0201b30:	ff040513          	addi	a0,s0,-16
}
ffffffffc0201b34:	6442                	ld	s0,16(sp)
ffffffffc0201b36:	60e2                	ld	ra,24(sp)
ffffffffc0201b38:	64a2                	ld	s1,8(sp)
	slob_free((slob_t *)block - 1, 0);
ffffffffc0201b3a:	4581                	li	a1,0
}
ffffffffc0201b3c:	6105                	addi	sp,sp,32
	slob_free((slob_t *)block - 1, 0);
ffffffffc0201b3e:	b9bd                	j	ffffffffc02017bc <slob_free>
        intr_disable();
ffffffffc0201b40:	df1fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
		for (bb = bigblocks; bb; last = &bb->next, bb = bb->next)
ffffffffc0201b44:	0000c797          	auipc	a5,0xc
ffffffffc0201b48:	9547b783          	ld	a5,-1708(a5) # ffffffffc020d498 <bigblocks>
        return 1;
ffffffffc0201b4c:	4605                	li	a2,1
ffffffffc0201b4e:	fbad                	bnez	a5,ffffffffc0201ac0 <kfree+0x26>
        intr_enable();
ffffffffc0201b50:	ddbfe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0201b54:	bff1                	j	ffffffffc0201b30 <kfree+0x96>
ffffffffc0201b56:	dd5fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0201b5a:	b751                	j	ffffffffc0201ade <kfree+0x44>
ffffffffc0201b5c:	8082                	ret
        panic("pa2page called with invalid pa");
ffffffffc0201b5e:	00003617          	auipc	a2,0x3
ffffffffc0201b62:	16260613          	addi	a2,a2,354 # ffffffffc0204cc0 <best_fit_pmm_manager+0x108>
ffffffffc0201b66:	06900593          	li	a1,105
ffffffffc0201b6a:	00003517          	auipc	a0,0x3
ffffffffc0201b6e:	0ae50513          	addi	a0,a0,174 # ffffffffc0204c18 <best_fit_pmm_manager+0x60>
ffffffffc0201b72:	8e9fe0ef          	jal	ra,ffffffffc020045a <__panic>
    return pa2page(PADDR(kva));
ffffffffc0201b76:	86a2                	mv	a3,s0
ffffffffc0201b78:	00003617          	auipc	a2,0x3
ffffffffc0201b7c:	12060613          	addi	a2,a2,288 # ffffffffc0204c98 <best_fit_pmm_manager+0xe0>
ffffffffc0201b80:	07700593          	li	a1,119
ffffffffc0201b84:	00003517          	auipc	a0,0x3
ffffffffc0201b88:	09450513          	addi	a0,a0,148 # ffffffffc0204c18 <best_fit_pmm_manager+0x60>
ffffffffc0201b8c:	8cffe0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0201b90 <pa2page.part.0>:
pa2page(uintptr_t pa)
ffffffffc0201b90:	1141                	addi	sp,sp,-16
        panic("pa2page called with invalid pa");
ffffffffc0201b92:	00003617          	auipc	a2,0x3
ffffffffc0201b96:	12e60613          	addi	a2,a2,302 # ffffffffc0204cc0 <best_fit_pmm_manager+0x108>
ffffffffc0201b9a:	06900593          	li	a1,105
ffffffffc0201b9e:	00003517          	auipc	a0,0x3
ffffffffc0201ba2:	07a50513          	addi	a0,a0,122 # ffffffffc0204c18 <best_fit_pmm_manager+0x60>
pa2page(uintptr_t pa)
ffffffffc0201ba6:	e406                	sd	ra,8(sp)
        panic("pa2page called with invalid pa");
ffffffffc0201ba8:	8b3fe0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0201bac <pte2page.part.0>:
pte2page(pte_t pte)
ffffffffc0201bac:	1141                	addi	sp,sp,-16
        panic("pte2page called with invalid pte");
ffffffffc0201bae:	00003617          	auipc	a2,0x3
ffffffffc0201bb2:	13260613          	addi	a2,a2,306 # ffffffffc0204ce0 <best_fit_pmm_manager+0x128>
ffffffffc0201bb6:	07f00593          	li	a1,127
ffffffffc0201bba:	00003517          	auipc	a0,0x3
ffffffffc0201bbe:	05e50513          	addi	a0,a0,94 # ffffffffc0204c18 <best_fit_pmm_manager+0x60>
pte2page(pte_t pte)
ffffffffc0201bc2:	e406                	sd	ra,8(sp)
        panic("pte2page called with invalid pte");
ffffffffc0201bc4:	897fe0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0201bc8 <alloc_pages>:
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0201bc8:	100027f3          	csrr	a5,sstatus
ffffffffc0201bcc:	8b89                	andi	a5,a5,2
ffffffffc0201bce:	e799                	bnez	a5,ffffffffc0201bdc <alloc_pages+0x14>
{
    struct Page *page = NULL;
    bool intr_flag;
    local_intr_save(intr_flag);
    {
        page = pmm_manager->alloc_pages(n);
ffffffffc0201bd0:	0000c797          	auipc	a5,0xc
ffffffffc0201bd4:	8f07b783          	ld	a5,-1808(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201bd8:	6f9c                	ld	a5,24(a5)
ffffffffc0201bda:	8782                	jr	a5
{
ffffffffc0201bdc:	1141                	addi	sp,sp,-16
ffffffffc0201bde:	e406                	sd	ra,8(sp)
ffffffffc0201be0:	e022                	sd	s0,0(sp)
ffffffffc0201be2:	842a                	mv	s0,a0
        intr_disable();
ffffffffc0201be4:	d4dfe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        page = pmm_manager->alloc_pages(n);
ffffffffc0201be8:	0000c797          	auipc	a5,0xc
ffffffffc0201bec:	8d87b783          	ld	a5,-1832(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201bf0:	6f9c                	ld	a5,24(a5)
ffffffffc0201bf2:	8522                	mv	a0,s0
ffffffffc0201bf4:	9782                	jalr	a5
ffffffffc0201bf6:	842a                	mv	s0,a0
        intr_enable();
ffffffffc0201bf8:	d33fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
    }
    local_intr_restore(intr_flag);
    return page;
}
ffffffffc0201bfc:	60a2                	ld	ra,8(sp)
ffffffffc0201bfe:	8522                	mv	a0,s0
ffffffffc0201c00:	6402                	ld	s0,0(sp)
ffffffffc0201c02:	0141                	addi	sp,sp,16
ffffffffc0201c04:	8082                	ret

ffffffffc0201c06 <free_pages>:
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0201c06:	100027f3          	csrr	a5,sstatus
ffffffffc0201c0a:	8b89                	andi	a5,a5,2
ffffffffc0201c0c:	e799                	bnez	a5,ffffffffc0201c1a <free_pages+0x14>
void free_pages(struct Page *base, size_t n)
{
    bool intr_flag;
    local_intr_save(intr_flag);
    {
        pmm_manager->free_pages(base, n);
ffffffffc0201c0e:	0000c797          	auipc	a5,0xc
ffffffffc0201c12:	8b27b783          	ld	a5,-1870(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201c16:	739c                	ld	a5,32(a5)
ffffffffc0201c18:	8782                	jr	a5
{
ffffffffc0201c1a:	1101                	addi	sp,sp,-32
ffffffffc0201c1c:	ec06                	sd	ra,24(sp)
ffffffffc0201c1e:	e822                	sd	s0,16(sp)
ffffffffc0201c20:	e426                	sd	s1,8(sp)
ffffffffc0201c22:	842a                	mv	s0,a0
ffffffffc0201c24:	84ae                	mv	s1,a1
        intr_disable();
ffffffffc0201c26:	d0bfe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        pmm_manager->free_pages(base, n);
ffffffffc0201c2a:	0000c797          	auipc	a5,0xc
ffffffffc0201c2e:	8967b783          	ld	a5,-1898(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201c32:	739c                	ld	a5,32(a5)
ffffffffc0201c34:	85a6                	mv	a1,s1
ffffffffc0201c36:	8522                	mv	a0,s0
ffffffffc0201c38:	9782                	jalr	a5
    }
    local_intr_restore(intr_flag);
}
ffffffffc0201c3a:	6442                	ld	s0,16(sp)
ffffffffc0201c3c:	60e2                	ld	ra,24(sp)
ffffffffc0201c3e:	64a2                	ld	s1,8(sp)
ffffffffc0201c40:	6105                	addi	sp,sp,32
        intr_enable();
ffffffffc0201c42:	ce9fe06f          	j	ffffffffc020092a <intr_enable>

ffffffffc0201c46 <nr_free_pages>:
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0201c46:	100027f3          	csrr	a5,sstatus
ffffffffc0201c4a:	8b89                	andi	a5,a5,2
ffffffffc0201c4c:	e799                	bnez	a5,ffffffffc0201c5a <nr_free_pages+0x14>
{
    size_t ret;
    bool intr_flag;
    local_intr_save(intr_flag);
    {
        ret = pmm_manager->nr_free_pages();
ffffffffc0201c4e:	0000c797          	auipc	a5,0xc
ffffffffc0201c52:	8727b783          	ld	a5,-1934(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201c56:	779c                	ld	a5,40(a5)
ffffffffc0201c58:	8782                	jr	a5
{
ffffffffc0201c5a:	1141                	addi	sp,sp,-16
ffffffffc0201c5c:	e406                	sd	ra,8(sp)
ffffffffc0201c5e:	e022                	sd	s0,0(sp)
        intr_disable();
ffffffffc0201c60:	cd1fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        ret = pmm_manager->nr_free_pages();
ffffffffc0201c64:	0000c797          	auipc	a5,0xc
ffffffffc0201c68:	85c7b783          	ld	a5,-1956(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201c6c:	779c                	ld	a5,40(a5)
ffffffffc0201c6e:	9782                	jalr	a5
ffffffffc0201c70:	842a                	mv	s0,a0
        intr_enable();
ffffffffc0201c72:	cb9fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
    }
    local_intr_restore(intr_flag);
    return ret;
}
ffffffffc0201c76:	60a2                	ld	ra,8(sp)
ffffffffc0201c78:	8522                	mv	a0,s0
ffffffffc0201c7a:	6402                	ld	s0,0(sp)
ffffffffc0201c7c:	0141                	addi	sp,sp,16
ffffffffc0201c7e:	8082                	ret

ffffffffc0201c80 <get_pte>:
//  la:     the linear address need to map
//  create: a logical value to decide if alloc a page for PT
// return vaule: the kernel virtual address of this pte
pte_t *get_pte(pde_t *pgdir, uintptr_t la, bool create)
{
    pde_t *pdep1 = &pgdir[PDX1(la)];
ffffffffc0201c80:	01e5d793          	srli	a5,a1,0x1e
ffffffffc0201c84:	1ff7f793          	andi	a5,a5,511
{
ffffffffc0201c88:	7139                	addi	sp,sp,-64
    pde_t *pdep1 = &pgdir[PDX1(la)];
ffffffffc0201c8a:	078e                	slli	a5,a5,0x3
{
ffffffffc0201c8c:	f426                	sd	s1,40(sp)
    pde_t *pdep1 = &pgdir[PDX1(la)];
ffffffffc0201c8e:	00f504b3          	add	s1,a0,a5
    if (!(*pdep1 & PTE_V))
ffffffffc0201c92:	6094                	ld	a3,0(s1)
{
ffffffffc0201c94:	f04a                	sd	s2,32(sp)
ffffffffc0201c96:	ec4e                	sd	s3,24(sp)
ffffffffc0201c98:	e852                	sd	s4,16(sp)
ffffffffc0201c9a:	fc06                	sd	ra,56(sp)
ffffffffc0201c9c:	f822                	sd	s0,48(sp)
ffffffffc0201c9e:	e456                	sd	s5,8(sp)
ffffffffc0201ca0:	e05a                	sd	s6,0(sp)
    if (!(*pdep1 & PTE_V))
ffffffffc0201ca2:	0016f793          	andi	a5,a3,1
{
ffffffffc0201ca6:	892e                	mv	s2,a1
ffffffffc0201ca8:	8a32                	mv	s4,a2
ffffffffc0201caa:	0000c997          	auipc	s3,0xc
ffffffffc0201cae:	80698993          	addi	s3,s3,-2042 # ffffffffc020d4b0 <npage>
    if (!(*pdep1 & PTE_V))
ffffffffc0201cb2:	efbd                	bnez	a5,ffffffffc0201d30 <get_pte+0xb0>
    {
        struct Page *page;
        if (!create || (page = alloc_page()) == NULL)
ffffffffc0201cb4:	14060c63          	beqz	a2,ffffffffc0201e0c <get_pte+0x18c>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0201cb8:	100027f3          	csrr	a5,sstatus
ffffffffc0201cbc:	8b89                	andi	a5,a5,2
ffffffffc0201cbe:	14079963          	bnez	a5,ffffffffc0201e10 <get_pte+0x190>
        page = pmm_manager->alloc_pages(n);
ffffffffc0201cc2:	0000b797          	auipc	a5,0xb
ffffffffc0201cc6:	7fe7b783          	ld	a5,2046(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201cca:	6f9c                	ld	a5,24(a5)
ffffffffc0201ccc:	4505                	li	a0,1
ffffffffc0201cce:	9782                	jalr	a5
ffffffffc0201cd0:	842a                	mv	s0,a0
        if (!create || (page = alloc_page()) == NULL)
ffffffffc0201cd2:	12040d63          	beqz	s0,ffffffffc0201e0c <get_pte+0x18c>
    return page - pages + nbase;
ffffffffc0201cd6:	0000bb17          	auipc	s6,0xb
ffffffffc0201cda:	7e2b0b13          	addi	s6,s6,2018 # ffffffffc020d4b8 <pages>
ffffffffc0201cde:	000b3503          	ld	a0,0(s6)
ffffffffc0201ce2:	00080ab7          	lui	s5,0x80
        {
            return NULL;
        }
        set_page_ref(page, 1);
        uintptr_t pa = page2pa(page);
        memset(KADDR(pa), 0, PGSIZE);
ffffffffc0201ce6:	0000b997          	auipc	s3,0xb
ffffffffc0201cea:	7ca98993          	addi	s3,s3,1994 # ffffffffc020d4b0 <npage>
ffffffffc0201cee:	40a40533          	sub	a0,s0,a0
ffffffffc0201cf2:	8519                	srai	a0,a0,0x6
ffffffffc0201cf4:	9556                	add	a0,a0,s5
ffffffffc0201cf6:	0009b703          	ld	a4,0(s3)
ffffffffc0201cfa:	00c51793          	slli	a5,a0,0xc
    page->ref = val;
ffffffffc0201cfe:	4685                	li	a3,1
ffffffffc0201d00:	c014                	sw	a3,0(s0)
ffffffffc0201d02:	83b1                	srli	a5,a5,0xc
    return page2ppn(page) << PGSHIFT;
ffffffffc0201d04:	0532                	slli	a0,a0,0xc
ffffffffc0201d06:	16e7f763          	bgeu	a5,a4,ffffffffc0201e74 <get_pte+0x1f4>
ffffffffc0201d0a:	0000b797          	auipc	a5,0xb
ffffffffc0201d0e:	7be7b783          	ld	a5,1982(a5) # ffffffffc020d4c8 <va_pa_offset>
ffffffffc0201d12:	6605                	lui	a2,0x1
ffffffffc0201d14:	4581                	li	a1,0
ffffffffc0201d16:	953e                	add	a0,a0,a5
ffffffffc0201d18:	094020ef          	jal	ra,ffffffffc0203dac <memset>
    return page - pages + nbase;
ffffffffc0201d1c:	000b3683          	ld	a3,0(s6)
ffffffffc0201d20:	40d406b3          	sub	a3,s0,a3
ffffffffc0201d24:	8699                	srai	a3,a3,0x6
ffffffffc0201d26:	96d6                	add	a3,a3,s5
}

// construct PTE from a page and permission bits
static inline pte_t pte_create(uintptr_t ppn, int type)
{
    return (ppn << PTE_PPN_SHIFT) | PTE_V | type;
ffffffffc0201d28:	06aa                	slli	a3,a3,0xa
ffffffffc0201d2a:	0116e693          	ori	a3,a3,17
        *pdep1 = pte_create(page2ppn(page), PTE_U | PTE_V);
ffffffffc0201d2e:	e094                	sd	a3,0(s1)
    }
    pde_t *pdep0 = &((pte_t *)KADDR(PDE_ADDR(*pdep1)))[PDX0(la)];
ffffffffc0201d30:	77fd                	lui	a5,0xfffff
ffffffffc0201d32:	068a                	slli	a3,a3,0x2
ffffffffc0201d34:	0009b703          	ld	a4,0(s3)
ffffffffc0201d38:	8efd                	and	a3,a3,a5
ffffffffc0201d3a:	00c6d793          	srli	a5,a3,0xc
ffffffffc0201d3e:	10e7ff63          	bgeu	a5,a4,ffffffffc0201e5c <get_pte+0x1dc>
ffffffffc0201d42:	0000ba97          	auipc	s5,0xb
ffffffffc0201d46:	786a8a93          	addi	s5,s5,1926 # ffffffffc020d4c8 <va_pa_offset>
ffffffffc0201d4a:	000ab403          	ld	s0,0(s5)
ffffffffc0201d4e:	01595793          	srli	a5,s2,0x15
ffffffffc0201d52:	1ff7f793          	andi	a5,a5,511
ffffffffc0201d56:	96a2                	add	a3,a3,s0
ffffffffc0201d58:	00379413          	slli	s0,a5,0x3
ffffffffc0201d5c:	9436                	add	s0,s0,a3
    if (!(*pdep0 & PTE_V))
ffffffffc0201d5e:	6014                	ld	a3,0(s0)
ffffffffc0201d60:	0016f793          	andi	a5,a3,1
ffffffffc0201d64:	ebad                	bnez	a5,ffffffffc0201dd6 <get_pte+0x156>
    {
        struct Page *page;
        if (!create || (page = alloc_page()) == NULL)
ffffffffc0201d66:	0a0a0363          	beqz	s4,ffffffffc0201e0c <get_pte+0x18c>
ffffffffc0201d6a:	100027f3          	csrr	a5,sstatus
ffffffffc0201d6e:	8b89                	andi	a5,a5,2
ffffffffc0201d70:	efcd                	bnez	a5,ffffffffc0201e2a <get_pte+0x1aa>
        page = pmm_manager->alloc_pages(n);
ffffffffc0201d72:	0000b797          	auipc	a5,0xb
ffffffffc0201d76:	74e7b783          	ld	a5,1870(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201d7a:	6f9c                	ld	a5,24(a5)
ffffffffc0201d7c:	4505                	li	a0,1
ffffffffc0201d7e:	9782                	jalr	a5
ffffffffc0201d80:	84aa                	mv	s1,a0
        if (!create || (page = alloc_page()) == NULL)
ffffffffc0201d82:	c4c9                	beqz	s1,ffffffffc0201e0c <get_pte+0x18c>
    return page - pages + nbase;
ffffffffc0201d84:	0000bb17          	auipc	s6,0xb
ffffffffc0201d88:	734b0b13          	addi	s6,s6,1844 # ffffffffc020d4b8 <pages>
ffffffffc0201d8c:	000b3503          	ld	a0,0(s6)
ffffffffc0201d90:	00080a37          	lui	s4,0x80
        {
            return NULL;
        }
        set_page_ref(page, 1);
        uintptr_t pa = page2pa(page);
        memset(KADDR(pa), 0, PGSIZE);
ffffffffc0201d94:	0009b703          	ld	a4,0(s3)
ffffffffc0201d98:	40a48533          	sub	a0,s1,a0
ffffffffc0201d9c:	8519                	srai	a0,a0,0x6
ffffffffc0201d9e:	9552                	add	a0,a0,s4
ffffffffc0201da0:	00c51793          	slli	a5,a0,0xc
    page->ref = val;
ffffffffc0201da4:	4685                	li	a3,1
ffffffffc0201da6:	c094                	sw	a3,0(s1)
ffffffffc0201da8:	83b1                	srli	a5,a5,0xc
    return page2ppn(page) << PGSHIFT;
ffffffffc0201daa:	0532                	slli	a0,a0,0xc
ffffffffc0201dac:	0ee7f163          	bgeu	a5,a4,ffffffffc0201e8e <get_pte+0x20e>
ffffffffc0201db0:	000ab783          	ld	a5,0(s5)
ffffffffc0201db4:	6605                	lui	a2,0x1
ffffffffc0201db6:	4581                	li	a1,0
ffffffffc0201db8:	953e                	add	a0,a0,a5
ffffffffc0201dba:	7f3010ef          	jal	ra,ffffffffc0203dac <memset>
    return page - pages + nbase;
ffffffffc0201dbe:	000b3683          	ld	a3,0(s6)
ffffffffc0201dc2:	40d486b3          	sub	a3,s1,a3
ffffffffc0201dc6:	8699                	srai	a3,a3,0x6
ffffffffc0201dc8:	96d2                	add	a3,a3,s4
    return (ppn << PTE_PPN_SHIFT) | PTE_V | type;
ffffffffc0201dca:	06aa                	slli	a3,a3,0xa
ffffffffc0201dcc:	0116e693          	ori	a3,a3,17
        *pdep0 = pte_create(page2ppn(page), PTE_U | PTE_V);
ffffffffc0201dd0:	e014                	sd	a3,0(s0)
    }
    return &((pte_t *)KADDR(PDE_ADDR(*pdep0)))[PTX(la)];
ffffffffc0201dd2:	0009b703          	ld	a4,0(s3)
ffffffffc0201dd6:	068a                	slli	a3,a3,0x2
ffffffffc0201dd8:	757d                	lui	a0,0xfffff
ffffffffc0201dda:	8ee9                	and	a3,a3,a0
ffffffffc0201ddc:	00c6d793          	srli	a5,a3,0xc
ffffffffc0201de0:	06e7f263          	bgeu	a5,a4,ffffffffc0201e44 <get_pte+0x1c4>
ffffffffc0201de4:	000ab503          	ld	a0,0(s5)
ffffffffc0201de8:	00c95913          	srli	s2,s2,0xc
ffffffffc0201dec:	1ff97913          	andi	s2,s2,511
ffffffffc0201df0:	96aa                	add	a3,a3,a0
ffffffffc0201df2:	00391513          	slli	a0,s2,0x3
ffffffffc0201df6:	9536                	add	a0,a0,a3
}
ffffffffc0201df8:	70e2                	ld	ra,56(sp)
ffffffffc0201dfa:	7442                	ld	s0,48(sp)
ffffffffc0201dfc:	74a2                	ld	s1,40(sp)
ffffffffc0201dfe:	7902                	ld	s2,32(sp)
ffffffffc0201e00:	69e2                	ld	s3,24(sp)
ffffffffc0201e02:	6a42                	ld	s4,16(sp)
ffffffffc0201e04:	6aa2                	ld	s5,8(sp)
ffffffffc0201e06:	6b02                	ld	s6,0(sp)
ffffffffc0201e08:	6121                	addi	sp,sp,64
ffffffffc0201e0a:	8082                	ret
            return NULL;
ffffffffc0201e0c:	4501                	li	a0,0
ffffffffc0201e0e:	b7ed                	j	ffffffffc0201df8 <get_pte+0x178>
        intr_disable();
ffffffffc0201e10:	b21fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        page = pmm_manager->alloc_pages(n);
ffffffffc0201e14:	0000b797          	auipc	a5,0xb
ffffffffc0201e18:	6ac7b783          	ld	a5,1708(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201e1c:	6f9c                	ld	a5,24(a5)
ffffffffc0201e1e:	4505                	li	a0,1
ffffffffc0201e20:	9782                	jalr	a5
ffffffffc0201e22:	842a                	mv	s0,a0
        intr_enable();
ffffffffc0201e24:	b07fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0201e28:	b56d                	j	ffffffffc0201cd2 <get_pte+0x52>
        intr_disable();
ffffffffc0201e2a:	b07fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
ffffffffc0201e2e:	0000b797          	auipc	a5,0xb
ffffffffc0201e32:	6927b783          	ld	a5,1682(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201e36:	6f9c                	ld	a5,24(a5)
ffffffffc0201e38:	4505                	li	a0,1
ffffffffc0201e3a:	9782                	jalr	a5
ffffffffc0201e3c:	84aa                	mv	s1,a0
        intr_enable();
ffffffffc0201e3e:	aedfe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0201e42:	b781                	j	ffffffffc0201d82 <get_pte+0x102>
    return &((pte_t *)KADDR(PDE_ADDR(*pdep0)))[PTX(la)];
ffffffffc0201e44:	00003617          	auipc	a2,0x3
ffffffffc0201e48:	dac60613          	addi	a2,a2,-596 # ffffffffc0204bf0 <best_fit_pmm_manager+0x38>
ffffffffc0201e4c:	0fc00593          	li	a1,252
ffffffffc0201e50:	00003517          	auipc	a0,0x3
ffffffffc0201e54:	eb850513          	addi	a0,a0,-328 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0201e58:	e02fe0ef          	jal	ra,ffffffffc020045a <__panic>
    pde_t *pdep0 = &((pte_t *)KADDR(PDE_ADDR(*pdep1)))[PDX0(la)];
ffffffffc0201e5c:	00003617          	auipc	a2,0x3
ffffffffc0201e60:	d9460613          	addi	a2,a2,-620 # ffffffffc0204bf0 <best_fit_pmm_manager+0x38>
ffffffffc0201e64:	0ef00593          	li	a1,239
ffffffffc0201e68:	00003517          	auipc	a0,0x3
ffffffffc0201e6c:	ea050513          	addi	a0,a0,-352 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0201e70:	deafe0ef          	jal	ra,ffffffffc020045a <__panic>
        memset(KADDR(pa), 0, PGSIZE);
ffffffffc0201e74:	86aa                	mv	a3,a0
ffffffffc0201e76:	00003617          	auipc	a2,0x3
ffffffffc0201e7a:	d7a60613          	addi	a2,a2,-646 # ffffffffc0204bf0 <best_fit_pmm_manager+0x38>
ffffffffc0201e7e:	0ec00593          	li	a1,236
ffffffffc0201e82:	00003517          	auipc	a0,0x3
ffffffffc0201e86:	e8650513          	addi	a0,a0,-378 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0201e8a:	dd0fe0ef          	jal	ra,ffffffffc020045a <__panic>
        memset(KADDR(pa), 0, PGSIZE);
ffffffffc0201e8e:	86aa                	mv	a3,a0
ffffffffc0201e90:	00003617          	auipc	a2,0x3
ffffffffc0201e94:	d6060613          	addi	a2,a2,-672 # ffffffffc0204bf0 <best_fit_pmm_manager+0x38>
ffffffffc0201e98:	0f900593          	li	a1,249
ffffffffc0201e9c:	00003517          	auipc	a0,0x3
ffffffffc0201ea0:	e6c50513          	addi	a0,a0,-404 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0201ea4:	db6fe0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0201ea8 <get_page>:

// get_page - get related Page struct for linear address la using PDT pgdir
struct Page *get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store)
{
ffffffffc0201ea8:	1141                	addi	sp,sp,-16
ffffffffc0201eaa:	e022                	sd	s0,0(sp)
ffffffffc0201eac:	8432                	mv	s0,a2
    pte_t *ptep = get_pte(pgdir, la, 0);
ffffffffc0201eae:	4601                	li	a2,0
{
ffffffffc0201eb0:	e406                	sd	ra,8(sp)
    pte_t *ptep = get_pte(pgdir, la, 0);
ffffffffc0201eb2:	dcfff0ef          	jal	ra,ffffffffc0201c80 <get_pte>
    if (ptep_store != NULL)
ffffffffc0201eb6:	c011                	beqz	s0,ffffffffc0201eba <get_page+0x12>
    {
        *ptep_store = ptep;
ffffffffc0201eb8:	e008                	sd	a0,0(s0)
    }
    if (ptep != NULL && *ptep & PTE_V)
ffffffffc0201eba:	c511                	beqz	a0,ffffffffc0201ec6 <get_page+0x1e>
ffffffffc0201ebc:	611c                	ld	a5,0(a0)
    {
        return pte2page(*ptep);
    }
    return NULL;
ffffffffc0201ebe:	4501                	li	a0,0
    if (ptep != NULL && *ptep & PTE_V)
ffffffffc0201ec0:	0017f713          	andi	a4,a5,1
ffffffffc0201ec4:	e709                	bnez	a4,ffffffffc0201ece <get_page+0x26>
}
ffffffffc0201ec6:	60a2                	ld	ra,8(sp)
ffffffffc0201ec8:	6402                	ld	s0,0(sp)
ffffffffc0201eca:	0141                	addi	sp,sp,16
ffffffffc0201ecc:	8082                	ret
    return pa2page(PTE_ADDR(pte));
ffffffffc0201ece:	078a                	slli	a5,a5,0x2
ffffffffc0201ed0:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage)
ffffffffc0201ed2:	0000b717          	auipc	a4,0xb
ffffffffc0201ed6:	5de73703          	ld	a4,1502(a4) # ffffffffc020d4b0 <npage>
ffffffffc0201eda:	00e7ff63          	bgeu	a5,a4,ffffffffc0201ef8 <get_page+0x50>
ffffffffc0201ede:	60a2                	ld	ra,8(sp)
ffffffffc0201ee0:	6402                	ld	s0,0(sp)
    return &pages[PPN(pa) - nbase];
ffffffffc0201ee2:	fff80537          	lui	a0,0xfff80
ffffffffc0201ee6:	97aa                	add	a5,a5,a0
ffffffffc0201ee8:	079a                	slli	a5,a5,0x6
ffffffffc0201eea:	0000b517          	auipc	a0,0xb
ffffffffc0201eee:	5ce53503          	ld	a0,1486(a0) # ffffffffc020d4b8 <pages>
ffffffffc0201ef2:	953e                	add	a0,a0,a5
ffffffffc0201ef4:	0141                	addi	sp,sp,16
ffffffffc0201ef6:	8082                	ret
ffffffffc0201ef8:	c99ff0ef          	jal	ra,ffffffffc0201b90 <pa2page.part.0>

ffffffffc0201efc <page_remove>:
}

// page_remove - free an Page which is related linear address la and has an
// validated pte
void page_remove(pde_t *pgdir, uintptr_t la)
{
ffffffffc0201efc:	7179                	addi	sp,sp,-48
    pte_t *ptep = get_pte(pgdir, la, 0);
ffffffffc0201efe:	4601                	li	a2,0
{
ffffffffc0201f00:	ec26                	sd	s1,24(sp)
ffffffffc0201f02:	f406                	sd	ra,40(sp)
ffffffffc0201f04:	f022                	sd	s0,32(sp)
ffffffffc0201f06:	84ae                	mv	s1,a1
    pte_t *ptep = get_pte(pgdir, la, 0);
ffffffffc0201f08:	d79ff0ef          	jal	ra,ffffffffc0201c80 <get_pte>
    if (ptep != NULL)
ffffffffc0201f0c:	c511                	beqz	a0,ffffffffc0201f18 <page_remove+0x1c>
    if (*ptep & PTE_V)
ffffffffc0201f0e:	611c                	ld	a5,0(a0)
ffffffffc0201f10:	842a                	mv	s0,a0
ffffffffc0201f12:	0017f713          	andi	a4,a5,1
ffffffffc0201f16:	e711                	bnez	a4,ffffffffc0201f22 <page_remove+0x26>
    {
        page_remove_pte(pgdir, la, ptep);
    }
}
ffffffffc0201f18:	70a2                	ld	ra,40(sp)
ffffffffc0201f1a:	7402                	ld	s0,32(sp)
ffffffffc0201f1c:	64e2                	ld	s1,24(sp)
ffffffffc0201f1e:	6145                	addi	sp,sp,48
ffffffffc0201f20:	8082                	ret
    return pa2page(PTE_ADDR(pte));
ffffffffc0201f22:	078a                	slli	a5,a5,0x2
ffffffffc0201f24:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage)
ffffffffc0201f26:	0000b717          	auipc	a4,0xb
ffffffffc0201f2a:	58a73703          	ld	a4,1418(a4) # ffffffffc020d4b0 <npage>
ffffffffc0201f2e:	06e7f363          	bgeu	a5,a4,ffffffffc0201f94 <page_remove+0x98>
    return &pages[PPN(pa) - nbase];
ffffffffc0201f32:	fff80537          	lui	a0,0xfff80
ffffffffc0201f36:	97aa                	add	a5,a5,a0
ffffffffc0201f38:	079a                	slli	a5,a5,0x6
ffffffffc0201f3a:	0000b517          	auipc	a0,0xb
ffffffffc0201f3e:	57e53503          	ld	a0,1406(a0) # ffffffffc020d4b8 <pages>
ffffffffc0201f42:	953e                	add	a0,a0,a5
    page->ref -= 1;
ffffffffc0201f44:	411c                	lw	a5,0(a0)
ffffffffc0201f46:	fff7871b          	addiw	a4,a5,-1
ffffffffc0201f4a:	c118                	sw	a4,0(a0)
        if (page_ref(page) ==
ffffffffc0201f4c:	cb11                	beqz	a4,ffffffffc0201f60 <page_remove+0x64>
        *ptep = 0;                 //(5) clear second page table entry
ffffffffc0201f4e:	00043023          	sd	zero,0(s0)
// edited are the ones currently in use by the processor.
void tlb_invalidate(pde_t *pgdir, uintptr_t la)
{
    // flush_tlb();
    // The flush_tlb flush the entire TLB, is there any better way?
    asm volatile("sfence.vma %0" : : "r"(la));
ffffffffc0201f52:	12048073          	sfence.vma	s1
}
ffffffffc0201f56:	70a2                	ld	ra,40(sp)
ffffffffc0201f58:	7402                	ld	s0,32(sp)
ffffffffc0201f5a:	64e2                	ld	s1,24(sp)
ffffffffc0201f5c:	6145                	addi	sp,sp,48
ffffffffc0201f5e:	8082                	ret
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0201f60:	100027f3          	csrr	a5,sstatus
ffffffffc0201f64:	8b89                	andi	a5,a5,2
ffffffffc0201f66:	eb89                	bnez	a5,ffffffffc0201f78 <page_remove+0x7c>
        pmm_manager->free_pages(base, n);
ffffffffc0201f68:	0000b797          	auipc	a5,0xb
ffffffffc0201f6c:	5587b783          	ld	a5,1368(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201f70:	739c                	ld	a5,32(a5)
ffffffffc0201f72:	4585                	li	a1,1
ffffffffc0201f74:	9782                	jalr	a5
    if (flag) {
ffffffffc0201f76:	bfe1                	j	ffffffffc0201f4e <page_remove+0x52>
        intr_disable();
ffffffffc0201f78:	e42a                	sd	a0,8(sp)
ffffffffc0201f7a:	9b7fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
ffffffffc0201f7e:	0000b797          	auipc	a5,0xb
ffffffffc0201f82:	5427b783          	ld	a5,1346(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0201f86:	739c                	ld	a5,32(a5)
ffffffffc0201f88:	6522                	ld	a0,8(sp)
ffffffffc0201f8a:	4585                	li	a1,1
ffffffffc0201f8c:	9782                	jalr	a5
        intr_enable();
ffffffffc0201f8e:	99dfe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0201f92:	bf75                	j	ffffffffc0201f4e <page_remove+0x52>
ffffffffc0201f94:	bfdff0ef          	jal	ra,ffffffffc0201b90 <pa2page.part.0>

ffffffffc0201f98 <page_insert>:
{
ffffffffc0201f98:	7139                	addi	sp,sp,-64
ffffffffc0201f9a:	e852                	sd	s4,16(sp)
ffffffffc0201f9c:	8a32                	mv	s4,a2
ffffffffc0201f9e:	f822                	sd	s0,48(sp)
    pte_t *ptep = get_pte(pgdir, la, 1);
ffffffffc0201fa0:	4605                	li	a2,1
{
ffffffffc0201fa2:	842e                	mv	s0,a1
    pte_t *ptep = get_pte(pgdir, la, 1);
ffffffffc0201fa4:	85d2                	mv	a1,s4
{
ffffffffc0201fa6:	f426                	sd	s1,40(sp)
ffffffffc0201fa8:	fc06                	sd	ra,56(sp)
ffffffffc0201faa:	f04a                	sd	s2,32(sp)
ffffffffc0201fac:	ec4e                	sd	s3,24(sp)
ffffffffc0201fae:	e456                	sd	s5,8(sp)
ffffffffc0201fb0:	84b6                	mv	s1,a3
    pte_t *ptep = get_pte(pgdir, la, 1);
ffffffffc0201fb2:	ccfff0ef          	jal	ra,ffffffffc0201c80 <get_pte>
    if (ptep == NULL)
ffffffffc0201fb6:	c961                	beqz	a0,ffffffffc0202086 <page_insert+0xee>
    page->ref += 1;
ffffffffc0201fb8:	4014                	lw	a3,0(s0)
    if (*ptep & PTE_V)
ffffffffc0201fba:	611c                	ld	a5,0(a0)
ffffffffc0201fbc:	89aa                	mv	s3,a0
ffffffffc0201fbe:	0016871b          	addiw	a4,a3,1
ffffffffc0201fc2:	c018                	sw	a4,0(s0)
ffffffffc0201fc4:	0017f713          	andi	a4,a5,1
ffffffffc0201fc8:	ef05                	bnez	a4,ffffffffc0202000 <page_insert+0x68>
    return page - pages + nbase;
ffffffffc0201fca:	0000b717          	auipc	a4,0xb
ffffffffc0201fce:	4ee73703          	ld	a4,1262(a4) # ffffffffc020d4b8 <pages>
ffffffffc0201fd2:	8c19                	sub	s0,s0,a4
ffffffffc0201fd4:	000807b7          	lui	a5,0x80
ffffffffc0201fd8:	8419                	srai	s0,s0,0x6
ffffffffc0201fda:	943e                	add	s0,s0,a5
    return (ppn << PTE_PPN_SHIFT) | PTE_V | type;
ffffffffc0201fdc:	042a                	slli	s0,s0,0xa
ffffffffc0201fde:	8cc1                	or	s1,s1,s0
ffffffffc0201fe0:	0014e493          	ori	s1,s1,1
    *ptep = pte_create(page2ppn(page), PTE_V | perm);
ffffffffc0201fe4:	0099b023          	sd	s1,0(s3)
    asm volatile("sfence.vma %0" : : "r"(la));
ffffffffc0201fe8:	120a0073          	sfence.vma	s4
    return 0;
ffffffffc0201fec:	4501                	li	a0,0
}
ffffffffc0201fee:	70e2                	ld	ra,56(sp)
ffffffffc0201ff0:	7442                	ld	s0,48(sp)
ffffffffc0201ff2:	74a2                	ld	s1,40(sp)
ffffffffc0201ff4:	7902                	ld	s2,32(sp)
ffffffffc0201ff6:	69e2                	ld	s3,24(sp)
ffffffffc0201ff8:	6a42                	ld	s4,16(sp)
ffffffffc0201ffa:	6aa2                	ld	s5,8(sp)
ffffffffc0201ffc:	6121                	addi	sp,sp,64
ffffffffc0201ffe:	8082                	ret
    return pa2page(PTE_ADDR(pte));
ffffffffc0202000:	078a                	slli	a5,a5,0x2
ffffffffc0202002:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage)
ffffffffc0202004:	0000b717          	auipc	a4,0xb
ffffffffc0202008:	4ac73703          	ld	a4,1196(a4) # ffffffffc020d4b0 <npage>
ffffffffc020200c:	06e7ff63          	bgeu	a5,a4,ffffffffc020208a <page_insert+0xf2>
    return &pages[PPN(pa) - nbase];
ffffffffc0202010:	0000ba97          	auipc	s5,0xb
ffffffffc0202014:	4a8a8a93          	addi	s5,s5,1192 # ffffffffc020d4b8 <pages>
ffffffffc0202018:	000ab703          	ld	a4,0(s5)
ffffffffc020201c:	fff80937          	lui	s2,0xfff80
ffffffffc0202020:	993e                	add	s2,s2,a5
ffffffffc0202022:	091a                	slli	s2,s2,0x6
ffffffffc0202024:	993a                	add	s2,s2,a4
        if (p == page)
ffffffffc0202026:	01240c63          	beq	s0,s2,ffffffffc020203e <page_insert+0xa6>
    page->ref -= 1;
ffffffffc020202a:	00092783          	lw	a5,0(s2) # fffffffffff80000 <end+0x3fd72b14>
ffffffffc020202e:	fff7869b          	addiw	a3,a5,-1
ffffffffc0202032:	00d92023          	sw	a3,0(s2)
        if (page_ref(page) ==
ffffffffc0202036:	c691                	beqz	a3,ffffffffc0202042 <page_insert+0xaa>
    asm volatile("sfence.vma %0" : : "r"(la));
ffffffffc0202038:	120a0073          	sfence.vma	s4
}
ffffffffc020203c:	bf59                	j	ffffffffc0201fd2 <page_insert+0x3a>
ffffffffc020203e:	c014                	sw	a3,0(s0)
    return page->ref;
ffffffffc0202040:	bf49                	j	ffffffffc0201fd2 <page_insert+0x3a>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0202042:	100027f3          	csrr	a5,sstatus
ffffffffc0202046:	8b89                	andi	a5,a5,2
ffffffffc0202048:	ef91                	bnez	a5,ffffffffc0202064 <page_insert+0xcc>
        pmm_manager->free_pages(base, n);
ffffffffc020204a:	0000b797          	auipc	a5,0xb
ffffffffc020204e:	4767b783          	ld	a5,1142(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0202052:	739c                	ld	a5,32(a5)
ffffffffc0202054:	4585                	li	a1,1
ffffffffc0202056:	854a                	mv	a0,s2
ffffffffc0202058:	9782                	jalr	a5
    return page - pages + nbase;
ffffffffc020205a:	000ab703          	ld	a4,0(s5)
    asm volatile("sfence.vma %0" : : "r"(la));
ffffffffc020205e:	120a0073          	sfence.vma	s4
ffffffffc0202062:	bf85                	j	ffffffffc0201fd2 <page_insert+0x3a>
        intr_disable();
ffffffffc0202064:	8cdfe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        pmm_manager->free_pages(base, n);
ffffffffc0202068:	0000b797          	auipc	a5,0xb
ffffffffc020206c:	4587b783          	ld	a5,1112(a5) # ffffffffc020d4c0 <pmm_manager>
ffffffffc0202070:	739c                	ld	a5,32(a5)
ffffffffc0202072:	4585                	li	a1,1
ffffffffc0202074:	854a                	mv	a0,s2
ffffffffc0202076:	9782                	jalr	a5
        intr_enable();
ffffffffc0202078:	8b3fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc020207c:	000ab703          	ld	a4,0(s5)
    asm volatile("sfence.vma %0" : : "r"(la));
ffffffffc0202080:	120a0073          	sfence.vma	s4
ffffffffc0202084:	b7b9                	j	ffffffffc0201fd2 <page_insert+0x3a>
        return -E_NO_MEM;
ffffffffc0202086:	5571                	li	a0,-4
ffffffffc0202088:	b79d                	j	ffffffffc0201fee <page_insert+0x56>
ffffffffc020208a:	b07ff0ef          	jal	ra,ffffffffc0201b90 <pa2page.part.0>

ffffffffc020208e <pmm_init>:
    pmm_manager = &best_fit_pmm_manager;
ffffffffc020208e:	00003797          	auipc	a5,0x3
ffffffffc0202092:	b2a78793          	addi	a5,a5,-1238 # ffffffffc0204bb8 <best_fit_pmm_manager>
    cprintf("memory management: %s\n", pmm_manager->name);
ffffffffc0202096:	638c                	ld	a1,0(a5)
{
ffffffffc0202098:	7159                	addi	sp,sp,-112
ffffffffc020209a:	f85a                	sd	s6,48(sp)
    cprintf("memory management: %s\n", pmm_manager->name);
ffffffffc020209c:	00003517          	auipc	a0,0x3
ffffffffc02020a0:	c7c50513          	addi	a0,a0,-900 # ffffffffc0204d18 <best_fit_pmm_manager+0x160>
    pmm_manager = &best_fit_pmm_manager;
ffffffffc02020a4:	0000bb17          	auipc	s6,0xb
ffffffffc02020a8:	41cb0b13          	addi	s6,s6,1052 # ffffffffc020d4c0 <pmm_manager>
{
ffffffffc02020ac:	f486                	sd	ra,104(sp)
ffffffffc02020ae:	e8ca                	sd	s2,80(sp)
ffffffffc02020b0:	e4ce                	sd	s3,72(sp)
ffffffffc02020b2:	f0a2                	sd	s0,96(sp)
ffffffffc02020b4:	eca6                	sd	s1,88(sp)
ffffffffc02020b6:	e0d2                	sd	s4,64(sp)
ffffffffc02020b8:	fc56                	sd	s5,56(sp)
ffffffffc02020ba:	f45e                	sd	s7,40(sp)
ffffffffc02020bc:	f062                	sd	s8,32(sp)
ffffffffc02020be:	ec66                	sd	s9,24(sp)
    pmm_manager = &best_fit_pmm_manager;
ffffffffc02020c0:	00fb3023          	sd	a5,0(s6)
    cprintf("memory management: %s\n", pmm_manager->name);
ffffffffc02020c4:	8d0fe0ef          	jal	ra,ffffffffc0200194 <cprintf>
    pmm_manager->init();
ffffffffc02020c8:	000b3783          	ld	a5,0(s6)
    va_pa_offset = PHYSICAL_MEMORY_OFFSET;
ffffffffc02020cc:	0000b997          	auipc	s3,0xb
ffffffffc02020d0:	3fc98993          	addi	s3,s3,1020 # ffffffffc020d4c8 <va_pa_offset>
    pmm_manager->init();
ffffffffc02020d4:	679c                	ld	a5,8(a5)
ffffffffc02020d6:	9782                	jalr	a5
    va_pa_offset = PHYSICAL_MEMORY_OFFSET;
ffffffffc02020d8:	57f5                	li	a5,-3
ffffffffc02020da:	07fa                	slli	a5,a5,0x1e
ffffffffc02020dc:	00f9b023          	sd	a5,0(s3)
    uint64_t mem_begin = get_memory_base();
ffffffffc02020e0:	837fe0ef          	jal	ra,ffffffffc0200916 <get_memory_base>
ffffffffc02020e4:	892a                	mv	s2,a0
    uint64_t mem_size  = get_memory_size();
ffffffffc02020e6:	83bfe0ef          	jal	ra,ffffffffc0200920 <get_memory_size>
    if (mem_size == 0) {
ffffffffc02020ea:	200505e3          	beqz	a0,ffffffffc0202af4 <pmm_init+0xa66>
    uint64_t mem_end   = mem_begin + mem_size;
ffffffffc02020ee:	84aa                	mv	s1,a0
    cprintf("physcial memory map:\n");
ffffffffc02020f0:	00003517          	auipc	a0,0x3
ffffffffc02020f4:	c6050513          	addi	a0,a0,-928 # ffffffffc0204d50 <best_fit_pmm_manager+0x198>
ffffffffc02020f8:	89cfe0ef          	jal	ra,ffffffffc0200194 <cprintf>
    uint64_t mem_end   = mem_begin + mem_size;
ffffffffc02020fc:	00990433          	add	s0,s2,s1
    cprintf("  memory: 0x%08lx, [0x%08lx, 0x%08lx].\n", mem_size, mem_begin,
ffffffffc0202100:	fff40693          	addi	a3,s0,-1
ffffffffc0202104:	864a                	mv	a2,s2
ffffffffc0202106:	85a6                	mv	a1,s1
ffffffffc0202108:	00003517          	auipc	a0,0x3
ffffffffc020210c:	c6050513          	addi	a0,a0,-928 # ffffffffc0204d68 <best_fit_pmm_manager+0x1b0>
ffffffffc0202110:	884fe0ef          	jal	ra,ffffffffc0200194 <cprintf>
    npage = maxpa / PGSIZE;
ffffffffc0202114:	c8000737          	lui	a4,0xc8000
ffffffffc0202118:	87a2                	mv	a5,s0
ffffffffc020211a:	54876163          	bltu	a4,s0,ffffffffc020265c <pmm_init+0x5ce>
ffffffffc020211e:	757d                	lui	a0,0xfffff
ffffffffc0202120:	0000c617          	auipc	a2,0xc
ffffffffc0202124:	3cb60613          	addi	a2,a2,971 # ffffffffc020e4eb <end+0xfff>
ffffffffc0202128:	8e69                	and	a2,a2,a0
ffffffffc020212a:	0000b497          	auipc	s1,0xb
ffffffffc020212e:	38648493          	addi	s1,s1,902 # ffffffffc020d4b0 <npage>
ffffffffc0202132:	00c7d513          	srli	a0,a5,0xc
    pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);
ffffffffc0202136:	0000bb97          	auipc	s7,0xb
ffffffffc020213a:	382b8b93          	addi	s7,s7,898 # ffffffffc020d4b8 <pages>
    npage = maxpa / PGSIZE;
ffffffffc020213e:	e088                	sd	a0,0(s1)
    pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);
ffffffffc0202140:	00cbb023          	sd	a2,0(s7)
    for (size_t i = 0; i < npage - nbase; i++)
ffffffffc0202144:	000807b7          	lui	a5,0x80
    pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);
ffffffffc0202148:	86b2                	mv	a3,a2
    for (size_t i = 0; i < npage - nbase; i++)
ffffffffc020214a:	02f50863          	beq	a0,a5,ffffffffc020217a <pmm_init+0xec>
ffffffffc020214e:	4781                	li	a5,0
ffffffffc0202150:	4585                	li	a1,1
ffffffffc0202152:	fff806b7          	lui	a3,0xfff80
        SetPageReserved(pages + i);
ffffffffc0202156:	00679513          	slli	a0,a5,0x6
ffffffffc020215a:	9532                	add	a0,a0,a2
ffffffffc020215c:	00850713          	addi	a4,a0,8 # fffffffffffff008 <end+0x3fdf1b1c>
ffffffffc0202160:	40b7302f          	amoor.d	zero,a1,(a4)
    for (size_t i = 0; i < npage - nbase; i++)
ffffffffc0202164:	6088                	ld	a0,0(s1)
ffffffffc0202166:	0785                	addi	a5,a5,1
        SetPageReserved(pages + i);
ffffffffc0202168:	000bb603          	ld	a2,0(s7)
    for (size_t i = 0; i < npage - nbase; i++)
ffffffffc020216c:	00d50733          	add	a4,a0,a3
ffffffffc0202170:	fee7e3e3          	bltu	a5,a4,ffffffffc0202156 <pmm_init+0xc8>
    uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * (npage - nbase));
ffffffffc0202174:	071a                	slli	a4,a4,0x6
ffffffffc0202176:	00e606b3          	add	a3,a2,a4
ffffffffc020217a:	c02007b7          	lui	a5,0xc0200
ffffffffc020217e:	2ef6ece3          	bltu	a3,a5,ffffffffc0202c76 <pmm_init+0xbe8>
ffffffffc0202182:	0009b583          	ld	a1,0(s3)
    mem_end = ROUNDDOWN(mem_end, PGSIZE);
ffffffffc0202186:	77fd                	lui	a5,0xfffff
ffffffffc0202188:	8c7d                	and	s0,s0,a5
    uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * (npage - nbase));
ffffffffc020218a:	8e8d                	sub	a3,a3,a1
    if (freemem < mem_end)
ffffffffc020218c:	5086eb63          	bltu	a3,s0,ffffffffc02026a2 <pmm_init+0x614>
    cprintf("vapaofset is %llu\n", va_pa_offset);
ffffffffc0202190:	00003517          	auipc	a0,0x3
ffffffffc0202194:	c0050513          	addi	a0,a0,-1024 # ffffffffc0204d90 <best_fit_pmm_manager+0x1d8>
ffffffffc0202198:	ffdfd0ef          	jal	ra,ffffffffc0200194 <cprintf>
}

static void check_alloc_page(void)
{
    pmm_manager->check();
ffffffffc020219c:	000b3783          	ld	a5,0(s6)
    boot_pgdir_va = (pte_t *)boot_page_table_sv39;
ffffffffc02021a0:	0000b917          	auipc	s2,0xb
ffffffffc02021a4:	30890913          	addi	s2,s2,776 # ffffffffc020d4a8 <boot_pgdir_va>
    pmm_manager->check();
ffffffffc02021a8:	7b9c                	ld	a5,48(a5)
ffffffffc02021aa:	9782                	jalr	a5
    cprintf("check_alloc_page() succeeded!\n");
ffffffffc02021ac:	00003517          	auipc	a0,0x3
ffffffffc02021b0:	bfc50513          	addi	a0,a0,-1028 # ffffffffc0204da8 <best_fit_pmm_manager+0x1f0>
ffffffffc02021b4:	fe1fd0ef          	jal	ra,ffffffffc0200194 <cprintf>
    boot_pgdir_va = (pte_t *)boot_page_table_sv39;
ffffffffc02021b8:	00006697          	auipc	a3,0x6
ffffffffc02021bc:	e4868693          	addi	a3,a3,-440 # ffffffffc0208000 <boot_page_table_sv39>
ffffffffc02021c0:	00d93023          	sd	a3,0(s2)
    boot_pgdir_pa = PADDR(boot_pgdir_va);
ffffffffc02021c4:	c02007b7          	lui	a5,0xc0200
ffffffffc02021c8:	28f6ebe3          	bltu	a3,a5,ffffffffc0202c5e <pmm_init+0xbd0>
ffffffffc02021cc:	0009b783          	ld	a5,0(s3)
ffffffffc02021d0:	8e9d                	sub	a3,a3,a5
ffffffffc02021d2:	0000b797          	auipc	a5,0xb
ffffffffc02021d6:	2cd7b723          	sd	a3,718(a5) # ffffffffc020d4a0 <boot_pgdir_pa>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc02021da:	100027f3          	csrr	a5,sstatus
ffffffffc02021de:	8b89                	andi	a5,a5,2
ffffffffc02021e0:	4a079763          	bnez	a5,ffffffffc020268e <pmm_init+0x600>
        ret = pmm_manager->nr_free_pages();
ffffffffc02021e4:	000b3783          	ld	a5,0(s6)
ffffffffc02021e8:	779c                	ld	a5,40(a5)
ffffffffc02021ea:	9782                	jalr	a5
ffffffffc02021ec:	842a                	mv	s0,a0
    // so npage is always larger than KMEMSIZE / PGSIZE
    size_t nr_free_store;

    nr_free_store = nr_free_pages();

    assert(npage <= KERNTOP / PGSIZE);
ffffffffc02021ee:	6098                	ld	a4,0(s1)
ffffffffc02021f0:	c80007b7          	lui	a5,0xc8000
ffffffffc02021f4:	83b1                	srli	a5,a5,0xc
ffffffffc02021f6:	66e7e363          	bltu	a5,a4,ffffffffc020285c <pmm_init+0x7ce>
    assert(boot_pgdir_va != NULL && (uint32_t)PGOFF(boot_pgdir_va) == 0);
ffffffffc02021fa:	00093503          	ld	a0,0(s2)
ffffffffc02021fe:	62050f63          	beqz	a0,ffffffffc020283c <pmm_init+0x7ae>
ffffffffc0202202:	03451793          	slli	a5,a0,0x34
ffffffffc0202206:	62079b63          	bnez	a5,ffffffffc020283c <pmm_init+0x7ae>
    assert(get_page(boot_pgdir_va, 0x0, NULL) == NULL);
ffffffffc020220a:	4601                	li	a2,0
ffffffffc020220c:	4581                	li	a1,0
ffffffffc020220e:	c9bff0ef          	jal	ra,ffffffffc0201ea8 <get_page>
ffffffffc0202212:	60051563          	bnez	a0,ffffffffc020281c <pmm_init+0x78e>
ffffffffc0202216:	100027f3          	csrr	a5,sstatus
ffffffffc020221a:	8b89                	andi	a5,a5,2
ffffffffc020221c:	44079e63          	bnez	a5,ffffffffc0202678 <pmm_init+0x5ea>
        page = pmm_manager->alloc_pages(n);
ffffffffc0202220:	000b3783          	ld	a5,0(s6)
ffffffffc0202224:	4505                	li	a0,1
ffffffffc0202226:	6f9c                	ld	a5,24(a5)
ffffffffc0202228:	9782                	jalr	a5
ffffffffc020222a:	8a2a                	mv	s4,a0

    struct Page *p1, *p2;
    p1 = alloc_page();
    assert(page_insert(boot_pgdir_va, p1, 0x0, 0) == 0);
ffffffffc020222c:	00093503          	ld	a0,0(s2)
ffffffffc0202230:	4681                	li	a3,0
ffffffffc0202232:	4601                	li	a2,0
ffffffffc0202234:	85d2                	mv	a1,s4
ffffffffc0202236:	d63ff0ef          	jal	ra,ffffffffc0201f98 <page_insert>
ffffffffc020223a:	26051ae3          	bnez	a0,ffffffffc0202cae <pmm_init+0xc20>

    pte_t *ptep;
    assert((ptep = get_pte(boot_pgdir_va, 0x0, 0)) != NULL);
ffffffffc020223e:	00093503          	ld	a0,0(s2)
ffffffffc0202242:	4601                	li	a2,0
ffffffffc0202244:	4581                	li	a1,0
ffffffffc0202246:	a3bff0ef          	jal	ra,ffffffffc0201c80 <get_pte>
ffffffffc020224a:	240502e3          	beqz	a0,ffffffffc0202c8e <pmm_init+0xc00>
    assert(pte2page(*ptep) == p1);
ffffffffc020224e:	611c                	ld	a5,0(a0)
    if (!(pte & PTE_V))
ffffffffc0202250:	0017f713          	andi	a4,a5,1
ffffffffc0202254:	5a070263          	beqz	a4,ffffffffc02027f8 <pmm_init+0x76a>
    if (PPN(pa) >= npage)
ffffffffc0202258:	6098                	ld	a4,0(s1)
    return pa2page(PTE_ADDR(pte));
ffffffffc020225a:	078a                	slli	a5,a5,0x2
ffffffffc020225c:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage)
ffffffffc020225e:	58e7fb63          	bgeu	a5,a4,ffffffffc02027f4 <pmm_init+0x766>
    return &pages[PPN(pa) - nbase];
ffffffffc0202262:	000bb683          	ld	a3,0(s7)
ffffffffc0202266:	fff80637          	lui	a2,0xfff80
ffffffffc020226a:	97b2                	add	a5,a5,a2
ffffffffc020226c:	079a                	slli	a5,a5,0x6
ffffffffc020226e:	97b6                	add	a5,a5,a3
ffffffffc0202270:	14fa17e3          	bne	s4,a5,ffffffffc0202bbe <pmm_init+0xb30>
    assert(page_ref(p1) == 1);
ffffffffc0202274:	000a2683          	lw	a3,0(s4) # 80000 <kern_entry-0xffffffffc0180000>
ffffffffc0202278:	4785                	li	a5,1
ffffffffc020227a:	12f692e3          	bne	a3,a5,ffffffffc0202b9e <pmm_init+0xb10>

    ptep = (pte_t *)KADDR(PDE_ADDR(boot_pgdir_va[0]));
ffffffffc020227e:	00093503          	ld	a0,0(s2)
ffffffffc0202282:	77fd                	lui	a5,0xfffff
ffffffffc0202284:	6114                	ld	a3,0(a0)
ffffffffc0202286:	068a                	slli	a3,a3,0x2
ffffffffc0202288:	8efd                	and	a3,a3,a5
ffffffffc020228a:	00c6d613          	srli	a2,a3,0xc
ffffffffc020228e:	0ee67ce3          	bgeu	a2,a4,ffffffffc0202b86 <pmm_init+0xaf8>
ffffffffc0202292:	0009bc03          	ld	s8,0(s3)
    ptep = (pte_t *)KADDR(PDE_ADDR(ptep[0])) + 1;
ffffffffc0202296:	96e2                	add	a3,a3,s8
ffffffffc0202298:	0006ba83          	ld	s5,0(a3)
ffffffffc020229c:	0a8a                	slli	s5,s5,0x2
ffffffffc020229e:	00fafab3          	and	s5,s5,a5
ffffffffc02022a2:	00cad793          	srli	a5,s5,0xc
ffffffffc02022a6:	0ce7f3e3          	bgeu	a5,a4,ffffffffc0202b6c <pmm_init+0xade>
    assert(get_pte(boot_pgdir_va, PGSIZE, 0) == ptep);
ffffffffc02022aa:	4601                	li	a2,0
ffffffffc02022ac:	6585                	lui	a1,0x1
    ptep = (pte_t *)KADDR(PDE_ADDR(ptep[0])) + 1;
ffffffffc02022ae:	9ae2                	add	s5,s5,s8
    assert(get_pte(boot_pgdir_va, PGSIZE, 0) == ptep);
ffffffffc02022b0:	9d1ff0ef          	jal	ra,ffffffffc0201c80 <get_pte>
    ptep = (pte_t *)KADDR(PDE_ADDR(ptep[0])) + 1;
ffffffffc02022b4:	0aa1                	addi	s5,s5,8
    assert(get_pte(boot_pgdir_va, PGSIZE, 0) == ptep);
ffffffffc02022b6:	55551363          	bne	a0,s5,ffffffffc02027fc <pmm_init+0x76e>
ffffffffc02022ba:	100027f3          	csrr	a5,sstatus
ffffffffc02022be:	8b89                	andi	a5,a5,2
ffffffffc02022c0:	3a079163          	bnez	a5,ffffffffc0202662 <pmm_init+0x5d4>
        page = pmm_manager->alloc_pages(n);
ffffffffc02022c4:	000b3783          	ld	a5,0(s6)
ffffffffc02022c8:	4505                	li	a0,1
ffffffffc02022ca:	6f9c                	ld	a5,24(a5)
ffffffffc02022cc:	9782                	jalr	a5
ffffffffc02022ce:	8c2a                	mv	s8,a0

    p2 = alloc_page();
    assert(page_insert(boot_pgdir_va, p2, PGSIZE, PTE_U | PTE_W) == 0);
ffffffffc02022d0:	00093503          	ld	a0,0(s2)
ffffffffc02022d4:	46d1                	li	a3,20
ffffffffc02022d6:	6605                	lui	a2,0x1
ffffffffc02022d8:	85e2                	mv	a1,s8
ffffffffc02022da:	cbfff0ef          	jal	ra,ffffffffc0201f98 <page_insert>
ffffffffc02022de:	060517e3          	bnez	a0,ffffffffc0202b4c <pmm_init+0xabe>
    assert((ptep = get_pte(boot_pgdir_va, PGSIZE, 0)) != NULL);
ffffffffc02022e2:	00093503          	ld	a0,0(s2)
ffffffffc02022e6:	4601                	li	a2,0
ffffffffc02022e8:	6585                	lui	a1,0x1
ffffffffc02022ea:	997ff0ef          	jal	ra,ffffffffc0201c80 <get_pte>
ffffffffc02022ee:	02050fe3          	beqz	a0,ffffffffc0202b2c <pmm_init+0xa9e>
    assert(*ptep & PTE_U);
ffffffffc02022f2:	611c                	ld	a5,0(a0)
ffffffffc02022f4:	0107f713          	andi	a4,a5,16
ffffffffc02022f8:	7c070e63          	beqz	a4,ffffffffc0202ad4 <pmm_init+0xa46>
    assert(*ptep & PTE_W);
ffffffffc02022fc:	8b91                	andi	a5,a5,4
ffffffffc02022fe:	7a078b63          	beqz	a5,ffffffffc0202ab4 <pmm_init+0xa26>
    assert(boot_pgdir_va[0] & PTE_U);
ffffffffc0202302:	00093503          	ld	a0,0(s2)
ffffffffc0202306:	611c                	ld	a5,0(a0)
ffffffffc0202308:	8bc1                	andi	a5,a5,16
ffffffffc020230a:	78078563          	beqz	a5,ffffffffc0202a94 <pmm_init+0xa06>
    assert(page_ref(p2) == 1);
ffffffffc020230e:	000c2703          	lw	a4,0(s8) # ff0000 <kern_entry-0xffffffffbf210000>
ffffffffc0202312:	4785                	li	a5,1
ffffffffc0202314:	76f71063          	bne	a4,a5,ffffffffc0202a74 <pmm_init+0x9e6>

    assert(page_insert(boot_pgdir_va, p1, PGSIZE, 0) == 0);
ffffffffc0202318:	4681                	li	a3,0
ffffffffc020231a:	6605                	lui	a2,0x1
ffffffffc020231c:	85d2                	mv	a1,s4
ffffffffc020231e:	c7bff0ef          	jal	ra,ffffffffc0201f98 <page_insert>
ffffffffc0202322:	72051963          	bnez	a0,ffffffffc0202a54 <pmm_init+0x9c6>
    assert(page_ref(p1) == 2);
ffffffffc0202326:	000a2703          	lw	a4,0(s4)
ffffffffc020232a:	4789                	li	a5,2
ffffffffc020232c:	70f71463          	bne	a4,a5,ffffffffc0202a34 <pmm_init+0x9a6>
    assert(page_ref(p2) == 0);
ffffffffc0202330:	000c2783          	lw	a5,0(s8)
ffffffffc0202334:	6e079063          	bnez	a5,ffffffffc0202a14 <pmm_init+0x986>
    assert((ptep = get_pte(boot_pgdir_va, PGSIZE, 0)) != NULL);
ffffffffc0202338:	00093503          	ld	a0,0(s2)
ffffffffc020233c:	4601                	li	a2,0
ffffffffc020233e:	6585                	lui	a1,0x1
ffffffffc0202340:	941ff0ef          	jal	ra,ffffffffc0201c80 <get_pte>
ffffffffc0202344:	6a050863          	beqz	a0,ffffffffc02029f4 <pmm_init+0x966>
    assert(pte2page(*ptep) == p1);
ffffffffc0202348:	6118                	ld	a4,0(a0)
    if (!(pte & PTE_V))
ffffffffc020234a:	00177793          	andi	a5,a4,1
ffffffffc020234e:	4a078563          	beqz	a5,ffffffffc02027f8 <pmm_init+0x76a>
    if (PPN(pa) >= npage)
ffffffffc0202352:	6094                	ld	a3,0(s1)
    return pa2page(PTE_ADDR(pte));
ffffffffc0202354:	00271793          	slli	a5,a4,0x2
ffffffffc0202358:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage)
ffffffffc020235a:	48d7fd63          	bgeu	a5,a3,ffffffffc02027f4 <pmm_init+0x766>
    return &pages[PPN(pa) - nbase];
ffffffffc020235e:	000bb683          	ld	a3,0(s7)
ffffffffc0202362:	fff80ab7          	lui	s5,0xfff80
ffffffffc0202366:	97d6                	add	a5,a5,s5
ffffffffc0202368:	079a                	slli	a5,a5,0x6
ffffffffc020236a:	97b6                	add	a5,a5,a3
ffffffffc020236c:	66fa1463          	bne	s4,a5,ffffffffc02029d4 <pmm_init+0x946>
    assert((*ptep & PTE_U) == 0);
ffffffffc0202370:	8b41                	andi	a4,a4,16
ffffffffc0202372:	64071163          	bnez	a4,ffffffffc02029b4 <pmm_init+0x926>

    page_remove(boot_pgdir_va, 0x0);
ffffffffc0202376:	00093503          	ld	a0,0(s2)
ffffffffc020237a:	4581                	li	a1,0
ffffffffc020237c:	b81ff0ef          	jal	ra,ffffffffc0201efc <page_remove>
    assert(page_ref(p1) == 1);
ffffffffc0202380:	000a2c83          	lw	s9,0(s4)
ffffffffc0202384:	4785                	li	a5,1
ffffffffc0202386:	60fc9763          	bne	s9,a5,ffffffffc0202994 <pmm_init+0x906>
    assert(page_ref(p2) == 0);
ffffffffc020238a:	000c2783          	lw	a5,0(s8)
ffffffffc020238e:	5e079363          	bnez	a5,ffffffffc0202974 <pmm_init+0x8e6>

    page_remove(boot_pgdir_va, PGSIZE);
ffffffffc0202392:	00093503          	ld	a0,0(s2)
ffffffffc0202396:	6585                	lui	a1,0x1
ffffffffc0202398:	b65ff0ef          	jal	ra,ffffffffc0201efc <page_remove>
    assert(page_ref(p1) == 0);
ffffffffc020239c:	000a2783          	lw	a5,0(s4)
ffffffffc02023a0:	52079a63          	bnez	a5,ffffffffc02028d4 <pmm_init+0x846>
    assert(page_ref(p2) == 0);
ffffffffc02023a4:	000c2783          	lw	a5,0(s8)
ffffffffc02023a8:	50079663          	bnez	a5,ffffffffc02028b4 <pmm_init+0x826>

    assert(page_ref(pde2page(boot_pgdir_va[0])) == 1);
ffffffffc02023ac:	00093a03          	ld	s4,0(s2)
    if (PPN(pa) >= npage)
ffffffffc02023b0:	608c                	ld	a1,0(s1)
    return pa2page(PDE_ADDR(pde));
ffffffffc02023b2:	000a3683          	ld	a3,0(s4)
ffffffffc02023b6:	068a                	slli	a3,a3,0x2
ffffffffc02023b8:	82b1                	srli	a3,a3,0xc
    if (PPN(pa) >= npage)
ffffffffc02023ba:	42b6fd63          	bgeu	a3,a1,ffffffffc02027f4 <pmm_init+0x766>
    return &pages[PPN(pa) - nbase];
ffffffffc02023be:	000bb503          	ld	a0,0(s7)
ffffffffc02023c2:	96d6                	add	a3,a3,s5
ffffffffc02023c4:	069a                	slli	a3,a3,0x6
    return page->ref;
ffffffffc02023c6:	00d507b3          	add	a5,a0,a3
ffffffffc02023ca:	439c                	lw	a5,0(a5)
ffffffffc02023cc:	4d979463          	bne	a5,s9,ffffffffc0202894 <pmm_init+0x806>
    return page - pages + nbase;
ffffffffc02023d0:	8699                	srai	a3,a3,0x6
ffffffffc02023d2:	00080637          	lui	a2,0x80
ffffffffc02023d6:	96b2                	add	a3,a3,a2
    return KADDR(page2pa(page));
ffffffffc02023d8:	00c69713          	slli	a4,a3,0xc
ffffffffc02023dc:	8331                	srli	a4,a4,0xc
    return page2ppn(page) << PGSHIFT;
ffffffffc02023de:	06b2                	slli	a3,a3,0xc
    return KADDR(page2pa(page));
ffffffffc02023e0:	48b77e63          	bgeu	a4,a1,ffffffffc020287c <pmm_init+0x7ee>

    pde_t *pd1 = boot_pgdir_va, *pd0 = page2kva(pde2page(boot_pgdir_va[0]));
    free_page(pde2page(pd0[0]));
ffffffffc02023e4:	0009b703          	ld	a4,0(s3)
ffffffffc02023e8:	96ba                	add	a3,a3,a4
    return pa2page(PDE_ADDR(pde));
ffffffffc02023ea:	629c                	ld	a5,0(a3)
ffffffffc02023ec:	078a                	slli	a5,a5,0x2
ffffffffc02023ee:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage)
ffffffffc02023f0:	40b7f263          	bgeu	a5,a1,ffffffffc02027f4 <pmm_init+0x766>
    return &pages[PPN(pa) - nbase];
ffffffffc02023f4:	8f91                	sub	a5,a5,a2
ffffffffc02023f6:	079a                	slli	a5,a5,0x6
ffffffffc02023f8:	953e                	add	a0,a0,a5
ffffffffc02023fa:	100027f3          	csrr	a5,sstatus
ffffffffc02023fe:	8b89                	andi	a5,a5,2
ffffffffc0202400:	30079963          	bnez	a5,ffffffffc0202712 <pmm_init+0x684>
        pmm_manager->free_pages(base, n);
ffffffffc0202404:	000b3783          	ld	a5,0(s6)
ffffffffc0202408:	4585                	li	a1,1
ffffffffc020240a:	739c                	ld	a5,32(a5)
ffffffffc020240c:	9782                	jalr	a5
    return pa2page(PDE_ADDR(pde));
ffffffffc020240e:	000a3783          	ld	a5,0(s4)
    if (PPN(pa) >= npage)
ffffffffc0202412:	6098                	ld	a4,0(s1)
    return pa2page(PDE_ADDR(pde));
ffffffffc0202414:	078a                	slli	a5,a5,0x2
ffffffffc0202416:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage)
ffffffffc0202418:	3ce7fe63          	bgeu	a5,a4,ffffffffc02027f4 <pmm_init+0x766>
    return &pages[PPN(pa) - nbase];
ffffffffc020241c:	000bb503          	ld	a0,0(s7)
ffffffffc0202420:	fff80737          	lui	a4,0xfff80
ffffffffc0202424:	97ba                	add	a5,a5,a4
ffffffffc0202426:	079a                	slli	a5,a5,0x6
ffffffffc0202428:	953e                	add	a0,a0,a5
ffffffffc020242a:	100027f3          	csrr	a5,sstatus
ffffffffc020242e:	8b89                	andi	a5,a5,2
ffffffffc0202430:	2c079563          	bnez	a5,ffffffffc02026fa <pmm_init+0x66c>
ffffffffc0202434:	000b3783          	ld	a5,0(s6)
ffffffffc0202438:	4585                	li	a1,1
ffffffffc020243a:	739c                	ld	a5,32(a5)
ffffffffc020243c:	9782                	jalr	a5
    free_page(pde2page(pd1[0]));
    boot_pgdir_va[0] = 0;
ffffffffc020243e:	00093783          	ld	a5,0(s2)
ffffffffc0202442:	0007b023          	sd	zero,0(a5) # fffffffffffff000 <end+0x3fdf1b14>
    asm volatile("sfence.vma");
ffffffffc0202446:	12000073          	sfence.vma
ffffffffc020244a:	100027f3          	csrr	a5,sstatus
ffffffffc020244e:	8b89                	andi	a5,a5,2
ffffffffc0202450:	28079b63          	bnez	a5,ffffffffc02026e6 <pmm_init+0x658>
        ret = pmm_manager->nr_free_pages();
ffffffffc0202454:	000b3783          	ld	a5,0(s6)
ffffffffc0202458:	779c                	ld	a5,40(a5)
ffffffffc020245a:	9782                	jalr	a5
ffffffffc020245c:	8a2a                	mv	s4,a0
    flush_tlb();

    assert(nr_free_store == nr_free_pages());
ffffffffc020245e:	4b441b63          	bne	s0,s4,ffffffffc0202914 <pmm_init+0x886>

    cprintf("check_pgdir() succeeded!\n");
ffffffffc0202462:	00003517          	auipc	a0,0x3
ffffffffc0202466:	c6e50513          	addi	a0,a0,-914 # ffffffffc02050d0 <best_fit_pmm_manager+0x518>
ffffffffc020246a:	d2bfd0ef          	jal	ra,ffffffffc0200194 <cprintf>
ffffffffc020246e:	100027f3          	csrr	a5,sstatus
ffffffffc0202472:	8b89                	andi	a5,a5,2
ffffffffc0202474:	24079f63          	bnez	a5,ffffffffc02026d2 <pmm_init+0x644>
        ret = pmm_manager->nr_free_pages();
ffffffffc0202478:	000b3783          	ld	a5,0(s6)
ffffffffc020247c:	779c                	ld	a5,40(a5)
ffffffffc020247e:	9782                	jalr	a5
ffffffffc0202480:	8c2a                	mv	s8,a0
    pte_t *ptep;
    int i;

    nr_free_store = nr_free_pages();

    for (i = ROUNDDOWN(KERNBASE, PGSIZE); i < npage * PGSIZE; i += PGSIZE)
ffffffffc0202482:	6098                	ld	a4,0(s1)
ffffffffc0202484:	c0200437          	lui	s0,0xc0200
    {
        assert((ptep = get_pte(boot_pgdir_va, (uintptr_t)KADDR(i), 0)) != NULL);
        assert(PTE_ADDR(*ptep) == i);
ffffffffc0202488:	7afd                	lui	s5,0xfffff
    for (i = ROUNDDOWN(KERNBASE, PGSIZE); i < npage * PGSIZE; i += PGSIZE)
ffffffffc020248a:	00c71793          	slli	a5,a4,0xc
ffffffffc020248e:	6a05                	lui	s4,0x1
ffffffffc0202490:	02f47c63          	bgeu	s0,a5,ffffffffc02024c8 <pmm_init+0x43a>
        assert((ptep = get_pte(boot_pgdir_va, (uintptr_t)KADDR(i), 0)) != NULL);
ffffffffc0202494:	00c45793          	srli	a5,s0,0xc
ffffffffc0202498:	00093503          	ld	a0,0(s2)
ffffffffc020249c:	2ee7ff63          	bgeu	a5,a4,ffffffffc020279a <pmm_init+0x70c>
ffffffffc02024a0:	0009b583          	ld	a1,0(s3)
ffffffffc02024a4:	4601                	li	a2,0
ffffffffc02024a6:	95a2                	add	a1,a1,s0
ffffffffc02024a8:	fd8ff0ef          	jal	ra,ffffffffc0201c80 <get_pte>
ffffffffc02024ac:	32050463          	beqz	a0,ffffffffc02027d4 <pmm_init+0x746>
        assert(PTE_ADDR(*ptep) == i);
ffffffffc02024b0:	611c                	ld	a5,0(a0)
ffffffffc02024b2:	078a                	slli	a5,a5,0x2
ffffffffc02024b4:	0157f7b3          	and	a5,a5,s5
ffffffffc02024b8:	2e879e63          	bne	a5,s0,ffffffffc02027b4 <pmm_init+0x726>
    for (i = ROUNDDOWN(KERNBASE, PGSIZE); i < npage * PGSIZE; i += PGSIZE)
ffffffffc02024bc:	6098                	ld	a4,0(s1)
ffffffffc02024be:	9452                	add	s0,s0,s4
ffffffffc02024c0:	00c71793          	slli	a5,a4,0xc
ffffffffc02024c4:	fcf468e3          	bltu	s0,a5,ffffffffc0202494 <pmm_init+0x406>
    }

    assert(boot_pgdir_va[0] == 0);
ffffffffc02024c8:	00093783          	ld	a5,0(s2)
ffffffffc02024cc:	639c                	ld	a5,0(a5)
ffffffffc02024ce:	42079363          	bnez	a5,ffffffffc02028f4 <pmm_init+0x866>
ffffffffc02024d2:	100027f3          	csrr	a5,sstatus
ffffffffc02024d6:	8b89                	andi	a5,a5,2
ffffffffc02024d8:	24079963          	bnez	a5,ffffffffc020272a <pmm_init+0x69c>
        page = pmm_manager->alloc_pages(n);
ffffffffc02024dc:	000b3783          	ld	a5,0(s6)
ffffffffc02024e0:	4505                	li	a0,1
ffffffffc02024e2:	6f9c                	ld	a5,24(a5)
ffffffffc02024e4:	9782                	jalr	a5
ffffffffc02024e6:	8a2a                	mv	s4,a0

    struct Page *p;
    p = alloc_page();
    assert(page_insert(boot_pgdir_va, p, 0x100, PTE_W | PTE_R) == 0);
ffffffffc02024e8:	00093503          	ld	a0,0(s2)
ffffffffc02024ec:	4699                	li	a3,6
ffffffffc02024ee:	10000613          	li	a2,256
ffffffffc02024f2:	85d2                	mv	a1,s4
ffffffffc02024f4:	aa5ff0ef          	jal	ra,ffffffffc0201f98 <page_insert>
ffffffffc02024f8:	44051e63          	bnez	a0,ffffffffc0202954 <pmm_init+0x8c6>
    assert(page_ref(p) == 1);
ffffffffc02024fc:	000a2703          	lw	a4,0(s4) # 1000 <kern_entry-0xffffffffc01ff000>
ffffffffc0202500:	4785                	li	a5,1
ffffffffc0202502:	42f71963          	bne	a4,a5,ffffffffc0202934 <pmm_init+0x8a6>
    assert(page_insert(boot_pgdir_va, p, 0x100 + PGSIZE, PTE_W | PTE_R) == 0);
ffffffffc0202506:	00093503          	ld	a0,0(s2)
ffffffffc020250a:	6405                	lui	s0,0x1
ffffffffc020250c:	4699                	li	a3,6
ffffffffc020250e:	10040613          	addi	a2,s0,256 # 1100 <kern_entry-0xffffffffc01fef00>
ffffffffc0202512:	85d2                	mv	a1,s4
ffffffffc0202514:	a85ff0ef          	jal	ra,ffffffffc0201f98 <page_insert>
ffffffffc0202518:	72051363          	bnez	a0,ffffffffc0202c3e <pmm_init+0xbb0>
    assert(page_ref(p) == 2);
ffffffffc020251c:	000a2703          	lw	a4,0(s4)
ffffffffc0202520:	4789                	li	a5,2
ffffffffc0202522:	6ef71e63          	bne	a4,a5,ffffffffc0202c1e <pmm_init+0xb90>

    const char *str = "ucore: Hello world!!";
    strcpy((void *)0x100, str);
ffffffffc0202526:	00003597          	auipc	a1,0x3
ffffffffc020252a:	cf258593          	addi	a1,a1,-782 # ffffffffc0205218 <best_fit_pmm_manager+0x660>
ffffffffc020252e:	10000513          	li	a0,256
ffffffffc0202532:	00f010ef          	jal	ra,ffffffffc0203d40 <strcpy>
    assert(strcmp((void *)0x100, (void *)(0x100 + PGSIZE)) == 0);
ffffffffc0202536:	10040593          	addi	a1,s0,256
ffffffffc020253a:	10000513          	li	a0,256
ffffffffc020253e:	015010ef          	jal	ra,ffffffffc0203d52 <strcmp>
ffffffffc0202542:	6a051e63          	bnez	a0,ffffffffc0202bfe <pmm_init+0xb70>
    return page - pages + nbase;
ffffffffc0202546:	000bb683          	ld	a3,0(s7)
ffffffffc020254a:	00080737          	lui	a4,0x80
    return KADDR(page2pa(page));
ffffffffc020254e:	547d                	li	s0,-1
    return page - pages + nbase;
ffffffffc0202550:	40da06b3          	sub	a3,s4,a3
ffffffffc0202554:	8699                	srai	a3,a3,0x6
    return KADDR(page2pa(page));
ffffffffc0202556:	609c                	ld	a5,0(s1)
    return page - pages + nbase;
ffffffffc0202558:	96ba                	add	a3,a3,a4
    return KADDR(page2pa(page));
ffffffffc020255a:	8031                	srli	s0,s0,0xc
ffffffffc020255c:	0086f733          	and	a4,a3,s0
    return page2ppn(page) << PGSHIFT;
ffffffffc0202560:	06b2                	slli	a3,a3,0xc
    return KADDR(page2pa(page));
ffffffffc0202562:	30f77d63          	bgeu	a4,a5,ffffffffc020287c <pmm_init+0x7ee>

    *(char *)(page2kva(p) + 0x100) = '\0';
ffffffffc0202566:	0009b783          	ld	a5,0(s3)
    assert(strlen((const char *)0x100) == 0);
ffffffffc020256a:	10000513          	li	a0,256
    *(char *)(page2kva(p) + 0x100) = '\0';
ffffffffc020256e:	96be                	add	a3,a3,a5
ffffffffc0202570:	10068023          	sb	zero,256(a3)
    assert(strlen((const char *)0x100) == 0);
ffffffffc0202574:	796010ef          	jal	ra,ffffffffc0203d0a <strlen>
ffffffffc0202578:	66051363          	bnez	a0,ffffffffc0202bde <pmm_init+0xb50>

    pde_t *pd1 = boot_pgdir_va, *pd0 = page2kva(pde2page(boot_pgdir_va[0]));
ffffffffc020257c:	00093a83          	ld	s5,0(s2)
    if (PPN(pa) >= npage)
ffffffffc0202580:	609c                	ld	a5,0(s1)
    return pa2page(PDE_ADDR(pde));
ffffffffc0202582:	000ab683          	ld	a3,0(s5) # fffffffffffff000 <end+0x3fdf1b14>
ffffffffc0202586:	068a                	slli	a3,a3,0x2
ffffffffc0202588:	82b1                	srli	a3,a3,0xc
    if (PPN(pa) >= npage)
ffffffffc020258a:	26f6f563          	bgeu	a3,a5,ffffffffc02027f4 <pmm_init+0x766>
    return KADDR(page2pa(page));
ffffffffc020258e:	8c75                	and	s0,s0,a3
    return page2ppn(page) << PGSHIFT;
ffffffffc0202590:	06b2                	slli	a3,a3,0xc
    return KADDR(page2pa(page));
ffffffffc0202592:	2ef47563          	bgeu	s0,a5,ffffffffc020287c <pmm_init+0x7ee>
ffffffffc0202596:	0009b403          	ld	s0,0(s3)
ffffffffc020259a:	9436                	add	s0,s0,a3
ffffffffc020259c:	100027f3          	csrr	a5,sstatus
ffffffffc02025a0:	8b89                	andi	a5,a5,2
ffffffffc02025a2:	1e079163          	bnez	a5,ffffffffc0202784 <pmm_init+0x6f6>
        pmm_manager->free_pages(base, n);
ffffffffc02025a6:	000b3783          	ld	a5,0(s6)
ffffffffc02025aa:	4585                	li	a1,1
ffffffffc02025ac:	8552                	mv	a0,s4
ffffffffc02025ae:	739c                	ld	a5,32(a5)
ffffffffc02025b0:	9782                	jalr	a5
    return pa2page(PDE_ADDR(pde));
ffffffffc02025b2:	601c                	ld	a5,0(s0)
    if (PPN(pa) >= npage)
ffffffffc02025b4:	6098                	ld	a4,0(s1)
    return pa2page(PDE_ADDR(pde));
ffffffffc02025b6:	078a                	slli	a5,a5,0x2
ffffffffc02025b8:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage)
ffffffffc02025ba:	22e7fd63          	bgeu	a5,a4,ffffffffc02027f4 <pmm_init+0x766>
    return &pages[PPN(pa) - nbase];
ffffffffc02025be:	000bb503          	ld	a0,0(s7)
ffffffffc02025c2:	fff80737          	lui	a4,0xfff80
ffffffffc02025c6:	97ba                	add	a5,a5,a4
ffffffffc02025c8:	079a                	slli	a5,a5,0x6
ffffffffc02025ca:	953e                	add	a0,a0,a5
ffffffffc02025cc:	100027f3          	csrr	a5,sstatus
ffffffffc02025d0:	8b89                	andi	a5,a5,2
ffffffffc02025d2:	18079d63          	bnez	a5,ffffffffc020276c <pmm_init+0x6de>
ffffffffc02025d6:	000b3783          	ld	a5,0(s6)
ffffffffc02025da:	4585                	li	a1,1
ffffffffc02025dc:	739c                	ld	a5,32(a5)
ffffffffc02025de:	9782                	jalr	a5
    return pa2page(PDE_ADDR(pde));
ffffffffc02025e0:	000ab783          	ld	a5,0(s5)
    if (PPN(pa) >= npage)
ffffffffc02025e4:	6098                	ld	a4,0(s1)
    return pa2page(PDE_ADDR(pde));
ffffffffc02025e6:	078a                	slli	a5,a5,0x2
ffffffffc02025e8:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage)
ffffffffc02025ea:	20e7f563          	bgeu	a5,a4,ffffffffc02027f4 <pmm_init+0x766>
    return &pages[PPN(pa) - nbase];
ffffffffc02025ee:	000bb503          	ld	a0,0(s7)
ffffffffc02025f2:	fff80737          	lui	a4,0xfff80
ffffffffc02025f6:	97ba                	add	a5,a5,a4
ffffffffc02025f8:	079a                	slli	a5,a5,0x6
ffffffffc02025fa:	953e                	add	a0,a0,a5
ffffffffc02025fc:	100027f3          	csrr	a5,sstatus
ffffffffc0202600:	8b89                	andi	a5,a5,2
ffffffffc0202602:	14079963          	bnez	a5,ffffffffc0202754 <pmm_init+0x6c6>
ffffffffc0202606:	000b3783          	ld	a5,0(s6)
ffffffffc020260a:	4585                	li	a1,1
ffffffffc020260c:	739c                	ld	a5,32(a5)
ffffffffc020260e:	9782                	jalr	a5
    free_page(p);
    free_page(pde2page(pd0[0]));
    free_page(pde2page(pd1[0]));
    boot_pgdir_va[0] = 0;
ffffffffc0202610:	00093783          	ld	a5,0(s2)
ffffffffc0202614:	0007b023          	sd	zero,0(a5)
    asm volatile("sfence.vma");
ffffffffc0202618:	12000073          	sfence.vma
ffffffffc020261c:	100027f3          	csrr	a5,sstatus
ffffffffc0202620:	8b89                	andi	a5,a5,2
ffffffffc0202622:	10079f63          	bnez	a5,ffffffffc0202740 <pmm_init+0x6b2>
        ret = pmm_manager->nr_free_pages();
ffffffffc0202626:	000b3783          	ld	a5,0(s6)
ffffffffc020262a:	779c                	ld	a5,40(a5)
ffffffffc020262c:	9782                	jalr	a5
ffffffffc020262e:	842a                	mv	s0,a0
    flush_tlb();

    assert(nr_free_store == nr_free_pages());
ffffffffc0202630:	4c8c1e63          	bne	s8,s0,ffffffffc0202b0c <pmm_init+0xa7e>

    cprintf("check_boot_pgdir() succeeded!\n");
ffffffffc0202634:	00003517          	auipc	a0,0x3
ffffffffc0202638:	c5c50513          	addi	a0,a0,-932 # ffffffffc0205290 <best_fit_pmm_manager+0x6d8>
ffffffffc020263c:	b59fd0ef          	jal	ra,ffffffffc0200194 <cprintf>
}
ffffffffc0202640:	7406                	ld	s0,96(sp)
ffffffffc0202642:	70a6                	ld	ra,104(sp)
ffffffffc0202644:	64e6                	ld	s1,88(sp)
ffffffffc0202646:	6946                	ld	s2,80(sp)
ffffffffc0202648:	69a6                	ld	s3,72(sp)
ffffffffc020264a:	6a06                	ld	s4,64(sp)
ffffffffc020264c:	7ae2                	ld	s5,56(sp)
ffffffffc020264e:	7b42                	ld	s6,48(sp)
ffffffffc0202650:	7ba2                	ld	s7,40(sp)
ffffffffc0202652:	7c02                	ld	s8,32(sp)
ffffffffc0202654:	6ce2                	ld	s9,24(sp)
ffffffffc0202656:	6165                	addi	sp,sp,112
    kmalloc_init();
ffffffffc0202658:	b72ff06f          	j	ffffffffc02019ca <kmalloc_init>
    npage = maxpa / PGSIZE;
ffffffffc020265c:	c80007b7          	lui	a5,0xc8000
ffffffffc0202660:	bc7d                	j	ffffffffc020211e <pmm_init+0x90>
        intr_disable();
ffffffffc0202662:	acefe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        page = pmm_manager->alloc_pages(n);
ffffffffc0202666:	000b3783          	ld	a5,0(s6)
ffffffffc020266a:	4505                	li	a0,1
ffffffffc020266c:	6f9c                	ld	a5,24(a5)
ffffffffc020266e:	9782                	jalr	a5
ffffffffc0202670:	8c2a                	mv	s8,a0
        intr_enable();
ffffffffc0202672:	ab8fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0202676:	b9a9                	j	ffffffffc02022d0 <pmm_init+0x242>
        intr_disable();
ffffffffc0202678:	ab8fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
ffffffffc020267c:	000b3783          	ld	a5,0(s6)
ffffffffc0202680:	4505                	li	a0,1
ffffffffc0202682:	6f9c                	ld	a5,24(a5)
ffffffffc0202684:	9782                	jalr	a5
ffffffffc0202686:	8a2a                	mv	s4,a0
        intr_enable();
ffffffffc0202688:	aa2fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc020268c:	b645                	j	ffffffffc020222c <pmm_init+0x19e>
        intr_disable();
ffffffffc020268e:	aa2fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        ret = pmm_manager->nr_free_pages();
ffffffffc0202692:	000b3783          	ld	a5,0(s6)
ffffffffc0202696:	779c                	ld	a5,40(a5)
ffffffffc0202698:	9782                	jalr	a5
ffffffffc020269a:	842a                	mv	s0,a0
        intr_enable();
ffffffffc020269c:	a8efe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc02026a0:	b6b9                	j	ffffffffc02021ee <pmm_init+0x160>
    mem_begin = ROUNDUP(freemem, PGSIZE);
ffffffffc02026a2:	6705                	lui	a4,0x1
ffffffffc02026a4:	177d                	addi	a4,a4,-1
ffffffffc02026a6:	96ba                	add	a3,a3,a4
ffffffffc02026a8:	8ff5                	and	a5,a5,a3
    if (PPN(pa) >= npage)
ffffffffc02026aa:	00c7d713          	srli	a4,a5,0xc
ffffffffc02026ae:	14a77363          	bgeu	a4,a0,ffffffffc02027f4 <pmm_init+0x766>
    pmm_manager->init_memmap(base, n);
ffffffffc02026b2:	000b3683          	ld	a3,0(s6)
    return &pages[PPN(pa) - nbase];
ffffffffc02026b6:	fff80537          	lui	a0,0xfff80
ffffffffc02026ba:	972a                	add	a4,a4,a0
ffffffffc02026bc:	6a94                	ld	a3,16(a3)
        init_memmap(pa2page(mem_begin), (mem_end - mem_begin) / PGSIZE);
ffffffffc02026be:	8c1d                	sub	s0,s0,a5
ffffffffc02026c0:	00671513          	slli	a0,a4,0x6
    pmm_manager->init_memmap(base, n);
ffffffffc02026c4:	00c45593          	srli	a1,s0,0xc
ffffffffc02026c8:	9532                	add	a0,a0,a2
ffffffffc02026ca:	9682                	jalr	a3
    cprintf("vapaofset is %llu\n", va_pa_offset);
ffffffffc02026cc:	0009b583          	ld	a1,0(s3)
}
ffffffffc02026d0:	b4c1                	j	ffffffffc0202190 <pmm_init+0x102>
        intr_disable();
ffffffffc02026d2:	a5efe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        ret = pmm_manager->nr_free_pages();
ffffffffc02026d6:	000b3783          	ld	a5,0(s6)
ffffffffc02026da:	779c                	ld	a5,40(a5)
ffffffffc02026dc:	9782                	jalr	a5
ffffffffc02026de:	8c2a                	mv	s8,a0
        intr_enable();
ffffffffc02026e0:	a4afe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc02026e4:	bb79                	j	ffffffffc0202482 <pmm_init+0x3f4>
        intr_disable();
ffffffffc02026e6:	a4afe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
ffffffffc02026ea:	000b3783          	ld	a5,0(s6)
ffffffffc02026ee:	779c                	ld	a5,40(a5)
ffffffffc02026f0:	9782                	jalr	a5
ffffffffc02026f2:	8a2a                	mv	s4,a0
        intr_enable();
ffffffffc02026f4:	a36fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc02026f8:	b39d                	j	ffffffffc020245e <pmm_init+0x3d0>
ffffffffc02026fa:	e42a                	sd	a0,8(sp)
        intr_disable();
ffffffffc02026fc:	a34fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        pmm_manager->free_pages(base, n);
ffffffffc0202700:	000b3783          	ld	a5,0(s6)
ffffffffc0202704:	6522                	ld	a0,8(sp)
ffffffffc0202706:	4585                	li	a1,1
ffffffffc0202708:	739c                	ld	a5,32(a5)
ffffffffc020270a:	9782                	jalr	a5
        intr_enable();
ffffffffc020270c:	a1efe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0202710:	b33d                	j	ffffffffc020243e <pmm_init+0x3b0>
ffffffffc0202712:	e42a                	sd	a0,8(sp)
        intr_disable();
ffffffffc0202714:	a1cfe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
ffffffffc0202718:	000b3783          	ld	a5,0(s6)
ffffffffc020271c:	6522                	ld	a0,8(sp)
ffffffffc020271e:	4585                	li	a1,1
ffffffffc0202720:	739c                	ld	a5,32(a5)
ffffffffc0202722:	9782                	jalr	a5
        intr_enable();
ffffffffc0202724:	a06fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0202728:	b1dd                	j	ffffffffc020240e <pmm_init+0x380>
        intr_disable();
ffffffffc020272a:	a06fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        page = pmm_manager->alloc_pages(n);
ffffffffc020272e:	000b3783          	ld	a5,0(s6)
ffffffffc0202732:	4505                	li	a0,1
ffffffffc0202734:	6f9c                	ld	a5,24(a5)
ffffffffc0202736:	9782                	jalr	a5
ffffffffc0202738:	8a2a                	mv	s4,a0
        intr_enable();
ffffffffc020273a:	9f0fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc020273e:	b36d                	j	ffffffffc02024e8 <pmm_init+0x45a>
        intr_disable();
ffffffffc0202740:	9f0fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        ret = pmm_manager->nr_free_pages();
ffffffffc0202744:	000b3783          	ld	a5,0(s6)
ffffffffc0202748:	779c                	ld	a5,40(a5)
ffffffffc020274a:	9782                	jalr	a5
ffffffffc020274c:	842a                	mv	s0,a0
        intr_enable();
ffffffffc020274e:	9dcfe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0202752:	bdf9                	j	ffffffffc0202630 <pmm_init+0x5a2>
ffffffffc0202754:	e42a                	sd	a0,8(sp)
        intr_disable();
ffffffffc0202756:	9dafe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        pmm_manager->free_pages(base, n);
ffffffffc020275a:	000b3783          	ld	a5,0(s6)
ffffffffc020275e:	6522                	ld	a0,8(sp)
ffffffffc0202760:	4585                	li	a1,1
ffffffffc0202762:	739c                	ld	a5,32(a5)
ffffffffc0202764:	9782                	jalr	a5
        intr_enable();
ffffffffc0202766:	9c4fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc020276a:	b55d                	j	ffffffffc0202610 <pmm_init+0x582>
ffffffffc020276c:	e42a                	sd	a0,8(sp)
        intr_disable();
ffffffffc020276e:	9c2fe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
ffffffffc0202772:	000b3783          	ld	a5,0(s6)
ffffffffc0202776:	6522                	ld	a0,8(sp)
ffffffffc0202778:	4585                	li	a1,1
ffffffffc020277a:	739c                	ld	a5,32(a5)
ffffffffc020277c:	9782                	jalr	a5
        intr_enable();
ffffffffc020277e:	9acfe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0202782:	bdb9                	j	ffffffffc02025e0 <pmm_init+0x552>
        intr_disable();
ffffffffc0202784:	9acfe0ef          	jal	ra,ffffffffc0200930 <intr_disable>
ffffffffc0202788:	000b3783          	ld	a5,0(s6)
ffffffffc020278c:	4585                	li	a1,1
ffffffffc020278e:	8552                	mv	a0,s4
ffffffffc0202790:	739c                	ld	a5,32(a5)
ffffffffc0202792:	9782                	jalr	a5
        intr_enable();
ffffffffc0202794:	996fe0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc0202798:	bd29                	j	ffffffffc02025b2 <pmm_init+0x524>
        assert((ptep = get_pte(boot_pgdir_va, (uintptr_t)KADDR(i), 0)) != NULL);
ffffffffc020279a:	86a2                	mv	a3,s0
ffffffffc020279c:	00002617          	auipc	a2,0x2
ffffffffc02027a0:	45460613          	addi	a2,a2,1108 # ffffffffc0204bf0 <best_fit_pmm_manager+0x38>
ffffffffc02027a4:	1a500593          	li	a1,421
ffffffffc02027a8:	00002517          	auipc	a0,0x2
ffffffffc02027ac:	56050513          	addi	a0,a0,1376 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc02027b0:	cabfd0ef          	jal	ra,ffffffffc020045a <__panic>
        assert(PTE_ADDR(*ptep) == i);
ffffffffc02027b4:	00003697          	auipc	a3,0x3
ffffffffc02027b8:	97c68693          	addi	a3,a3,-1668 # ffffffffc0205130 <best_fit_pmm_manager+0x578>
ffffffffc02027bc:	00002617          	auipc	a2,0x2
ffffffffc02027c0:	0bc60613          	addi	a2,a2,188 # ffffffffc0204878 <commands+0x810>
ffffffffc02027c4:	1a600593          	li	a1,422
ffffffffc02027c8:	00002517          	auipc	a0,0x2
ffffffffc02027cc:	54050513          	addi	a0,a0,1344 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc02027d0:	c8bfd0ef          	jal	ra,ffffffffc020045a <__panic>
        assert((ptep = get_pte(boot_pgdir_va, (uintptr_t)KADDR(i), 0)) != NULL);
ffffffffc02027d4:	00003697          	auipc	a3,0x3
ffffffffc02027d8:	91c68693          	addi	a3,a3,-1764 # ffffffffc02050f0 <best_fit_pmm_manager+0x538>
ffffffffc02027dc:	00002617          	auipc	a2,0x2
ffffffffc02027e0:	09c60613          	addi	a2,a2,156 # ffffffffc0204878 <commands+0x810>
ffffffffc02027e4:	1a500593          	li	a1,421
ffffffffc02027e8:	00002517          	auipc	a0,0x2
ffffffffc02027ec:	52050513          	addi	a0,a0,1312 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc02027f0:	c6bfd0ef          	jal	ra,ffffffffc020045a <__panic>
ffffffffc02027f4:	b9cff0ef          	jal	ra,ffffffffc0201b90 <pa2page.part.0>
ffffffffc02027f8:	bb4ff0ef          	jal	ra,ffffffffc0201bac <pte2page.part.0>
    assert(get_pte(boot_pgdir_va, PGSIZE, 0) == ptep);
ffffffffc02027fc:	00002697          	auipc	a3,0x2
ffffffffc0202800:	6ec68693          	addi	a3,a3,1772 # ffffffffc0204ee8 <best_fit_pmm_manager+0x330>
ffffffffc0202804:	00002617          	auipc	a2,0x2
ffffffffc0202808:	07460613          	addi	a2,a2,116 # ffffffffc0204878 <commands+0x810>
ffffffffc020280c:	17500593          	li	a1,373
ffffffffc0202810:	00002517          	auipc	a0,0x2
ffffffffc0202814:	4f850513          	addi	a0,a0,1272 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202818:	c43fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(get_page(boot_pgdir_va, 0x0, NULL) == NULL);
ffffffffc020281c:	00002697          	auipc	a3,0x2
ffffffffc0202820:	60c68693          	addi	a3,a3,1548 # ffffffffc0204e28 <best_fit_pmm_manager+0x270>
ffffffffc0202824:	00002617          	auipc	a2,0x2
ffffffffc0202828:	05460613          	addi	a2,a2,84 # ffffffffc0204878 <commands+0x810>
ffffffffc020282c:	16800593          	li	a1,360
ffffffffc0202830:	00002517          	auipc	a0,0x2
ffffffffc0202834:	4d850513          	addi	a0,a0,1240 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202838:	c23fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(boot_pgdir_va != NULL && (uint32_t)PGOFF(boot_pgdir_va) == 0);
ffffffffc020283c:	00002697          	auipc	a3,0x2
ffffffffc0202840:	5ac68693          	addi	a3,a3,1452 # ffffffffc0204de8 <best_fit_pmm_manager+0x230>
ffffffffc0202844:	00002617          	auipc	a2,0x2
ffffffffc0202848:	03460613          	addi	a2,a2,52 # ffffffffc0204878 <commands+0x810>
ffffffffc020284c:	16700593          	li	a1,359
ffffffffc0202850:	00002517          	auipc	a0,0x2
ffffffffc0202854:	4b850513          	addi	a0,a0,1208 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202858:	c03fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(npage <= KERNTOP / PGSIZE);
ffffffffc020285c:	00002697          	auipc	a3,0x2
ffffffffc0202860:	56c68693          	addi	a3,a3,1388 # ffffffffc0204dc8 <best_fit_pmm_manager+0x210>
ffffffffc0202864:	00002617          	auipc	a2,0x2
ffffffffc0202868:	01460613          	addi	a2,a2,20 # ffffffffc0204878 <commands+0x810>
ffffffffc020286c:	16600593          	li	a1,358
ffffffffc0202870:	00002517          	auipc	a0,0x2
ffffffffc0202874:	49850513          	addi	a0,a0,1176 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202878:	be3fd0ef          	jal	ra,ffffffffc020045a <__panic>
    return KADDR(page2pa(page));
ffffffffc020287c:	00002617          	auipc	a2,0x2
ffffffffc0202880:	37460613          	addi	a2,a2,884 # ffffffffc0204bf0 <best_fit_pmm_manager+0x38>
ffffffffc0202884:	07100593          	li	a1,113
ffffffffc0202888:	00002517          	auipc	a0,0x2
ffffffffc020288c:	39050513          	addi	a0,a0,912 # ffffffffc0204c18 <best_fit_pmm_manager+0x60>
ffffffffc0202890:	bcbfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(pde2page(boot_pgdir_va[0])) == 1);
ffffffffc0202894:	00002697          	auipc	a3,0x2
ffffffffc0202898:	7e468693          	addi	a3,a3,2020 # ffffffffc0205078 <best_fit_pmm_manager+0x4c0>
ffffffffc020289c:	00002617          	auipc	a2,0x2
ffffffffc02028a0:	fdc60613          	addi	a2,a2,-36 # ffffffffc0204878 <commands+0x810>
ffffffffc02028a4:	18e00593          	li	a1,398
ffffffffc02028a8:	00002517          	auipc	a0,0x2
ffffffffc02028ac:	46050513          	addi	a0,a0,1120 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc02028b0:	babfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(p2) == 0);
ffffffffc02028b4:	00002697          	auipc	a3,0x2
ffffffffc02028b8:	77c68693          	addi	a3,a3,1916 # ffffffffc0205030 <best_fit_pmm_manager+0x478>
ffffffffc02028bc:	00002617          	auipc	a2,0x2
ffffffffc02028c0:	fbc60613          	addi	a2,a2,-68 # ffffffffc0204878 <commands+0x810>
ffffffffc02028c4:	18c00593          	li	a1,396
ffffffffc02028c8:	00002517          	auipc	a0,0x2
ffffffffc02028cc:	44050513          	addi	a0,a0,1088 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc02028d0:	b8bfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(p1) == 0);
ffffffffc02028d4:	00002697          	auipc	a3,0x2
ffffffffc02028d8:	78c68693          	addi	a3,a3,1932 # ffffffffc0205060 <best_fit_pmm_manager+0x4a8>
ffffffffc02028dc:	00002617          	auipc	a2,0x2
ffffffffc02028e0:	f9c60613          	addi	a2,a2,-100 # ffffffffc0204878 <commands+0x810>
ffffffffc02028e4:	18b00593          	li	a1,395
ffffffffc02028e8:	00002517          	auipc	a0,0x2
ffffffffc02028ec:	42050513          	addi	a0,a0,1056 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc02028f0:	b6bfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(boot_pgdir_va[0] == 0);
ffffffffc02028f4:	00003697          	auipc	a3,0x3
ffffffffc02028f8:	85468693          	addi	a3,a3,-1964 # ffffffffc0205148 <best_fit_pmm_manager+0x590>
ffffffffc02028fc:	00002617          	auipc	a2,0x2
ffffffffc0202900:	f7c60613          	addi	a2,a2,-132 # ffffffffc0204878 <commands+0x810>
ffffffffc0202904:	1a900593          	li	a1,425
ffffffffc0202908:	00002517          	auipc	a0,0x2
ffffffffc020290c:	40050513          	addi	a0,a0,1024 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202910:	b4bfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(nr_free_store == nr_free_pages());
ffffffffc0202914:	00002697          	auipc	a3,0x2
ffffffffc0202918:	79468693          	addi	a3,a3,1940 # ffffffffc02050a8 <best_fit_pmm_manager+0x4f0>
ffffffffc020291c:	00002617          	auipc	a2,0x2
ffffffffc0202920:	f5c60613          	addi	a2,a2,-164 # ffffffffc0204878 <commands+0x810>
ffffffffc0202924:	19600593          	li	a1,406
ffffffffc0202928:	00002517          	auipc	a0,0x2
ffffffffc020292c:	3e050513          	addi	a0,a0,992 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202930:	b2bfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(p) == 1);
ffffffffc0202934:	00003697          	auipc	a3,0x3
ffffffffc0202938:	86c68693          	addi	a3,a3,-1940 # ffffffffc02051a0 <best_fit_pmm_manager+0x5e8>
ffffffffc020293c:	00002617          	auipc	a2,0x2
ffffffffc0202940:	f3c60613          	addi	a2,a2,-196 # ffffffffc0204878 <commands+0x810>
ffffffffc0202944:	1ae00593          	li	a1,430
ffffffffc0202948:	00002517          	auipc	a0,0x2
ffffffffc020294c:	3c050513          	addi	a0,a0,960 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202950:	b0bfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_insert(boot_pgdir_va, p, 0x100, PTE_W | PTE_R) == 0);
ffffffffc0202954:	00003697          	auipc	a3,0x3
ffffffffc0202958:	80c68693          	addi	a3,a3,-2036 # ffffffffc0205160 <best_fit_pmm_manager+0x5a8>
ffffffffc020295c:	00002617          	auipc	a2,0x2
ffffffffc0202960:	f1c60613          	addi	a2,a2,-228 # ffffffffc0204878 <commands+0x810>
ffffffffc0202964:	1ad00593          	li	a1,429
ffffffffc0202968:	00002517          	auipc	a0,0x2
ffffffffc020296c:	3a050513          	addi	a0,a0,928 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202970:	aebfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(p2) == 0);
ffffffffc0202974:	00002697          	auipc	a3,0x2
ffffffffc0202978:	6bc68693          	addi	a3,a3,1724 # ffffffffc0205030 <best_fit_pmm_manager+0x478>
ffffffffc020297c:	00002617          	auipc	a2,0x2
ffffffffc0202980:	efc60613          	addi	a2,a2,-260 # ffffffffc0204878 <commands+0x810>
ffffffffc0202984:	18800593          	li	a1,392
ffffffffc0202988:	00002517          	auipc	a0,0x2
ffffffffc020298c:	38050513          	addi	a0,a0,896 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202990:	acbfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(p1) == 1);
ffffffffc0202994:	00002697          	auipc	a3,0x2
ffffffffc0202998:	53c68693          	addi	a3,a3,1340 # ffffffffc0204ed0 <best_fit_pmm_manager+0x318>
ffffffffc020299c:	00002617          	auipc	a2,0x2
ffffffffc02029a0:	edc60613          	addi	a2,a2,-292 # ffffffffc0204878 <commands+0x810>
ffffffffc02029a4:	18700593          	li	a1,391
ffffffffc02029a8:	00002517          	auipc	a0,0x2
ffffffffc02029ac:	36050513          	addi	a0,a0,864 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc02029b0:	aabfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((*ptep & PTE_U) == 0);
ffffffffc02029b4:	00002697          	auipc	a3,0x2
ffffffffc02029b8:	69468693          	addi	a3,a3,1684 # ffffffffc0205048 <best_fit_pmm_manager+0x490>
ffffffffc02029bc:	00002617          	auipc	a2,0x2
ffffffffc02029c0:	ebc60613          	addi	a2,a2,-324 # ffffffffc0204878 <commands+0x810>
ffffffffc02029c4:	18400593          	li	a1,388
ffffffffc02029c8:	00002517          	auipc	a0,0x2
ffffffffc02029cc:	34050513          	addi	a0,a0,832 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc02029d0:	a8bfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(pte2page(*ptep) == p1);
ffffffffc02029d4:	00002697          	auipc	a3,0x2
ffffffffc02029d8:	4e468693          	addi	a3,a3,1252 # ffffffffc0204eb8 <best_fit_pmm_manager+0x300>
ffffffffc02029dc:	00002617          	auipc	a2,0x2
ffffffffc02029e0:	e9c60613          	addi	a2,a2,-356 # ffffffffc0204878 <commands+0x810>
ffffffffc02029e4:	18300593          	li	a1,387
ffffffffc02029e8:	00002517          	auipc	a0,0x2
ffffffffc02029ec:	32050513          	addi	a0,a0,800 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc02029f0:	a6bfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((ptep = get_pte(boot_pgdir_va, PGSIZE, 0)) != NULL);
ffffffffc02029f4:	00002697          	auipc	a3,0x2
ffffffffc02029f8:	56468693          	addi	a3,a3,1380 # ffffffffc0204f58 <best_fit_pmm_manager+0x3a0>
ffffffffc02029fc:	00002617          	auipc	a2,0x2
ffffffffc0202a00:	e7c60613          	addi	a2,a2,-388 # ffffffffc0204878 <commands+0x810>
ffffffffc0202a04:	18200593          	li	a1,386
ffffffffc0202a08:	00002517          	auipc	a0,0x2
ffffffffc0202a0c:	30050513          	addi	a0,a0,768 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202a10:	a4bfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(p2) == 0);
ffffffffc0202a14:	00002697          	auipc	a3,0x2
ffffffffc0202a18:	61c68693          	addi	a3,a3,1564 # ffffffffc0205030 <best_fit_pmm_manager+0x478>
ffffffffc0202a1c:	00002617          	auipc	a2,0x2
ffffffffc0202a20:	e5c60613          	addi	a2,a2,-420 # ffffffffc0204878 <commands+0x810>
ffffffffc0202a24:	18100593          	li	a1,385
ffffffffc0202a28:	00002517          	auipc	a0,0x2
ffffffffc0202a2c:	2e050513          	addi	a0,a0,736 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202a30:	a2bfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(p1) == 2);
ffffffffc0202a34:	00002697          	auipc	a3,0x2
ffffffffc0202a38:	5e468693          	addi	a3,a3,1508 # ffffffffc0205018 <best_fit_pmm_manager+0x460>
ffffffffc0202a3c:	00002617          	auipc	a2,0x2
ffffffffc0202a40:	e3c60613          	addi	a2,a2,-452 # ffffffffc0204878 <commands+0x810>
ffffffffc0202a44:	18000593          	li	a1,384
ffffffffc0202a48:	00002517          	auipc	a0,0x2
ffffffffc0202a4c:	2c050513          	addi	a0,a0,704 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202a50:	a0bfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_insert(boot_pgdir_va, p1, PGSIZE, 0) == 0);
ffffffffc0202a54:	00002697          	auipc	a3,0x2
ffffffffc0202a58:	59468693          	addi	a3,a3,1428 # ffffffffc0204fe8 <best_fit_pmm_manager+0x430>
ffffffffc0202a5c:	00002617          	auipc	a2,0x2
ffffffffc0202a60:	e1c60613          	addi	a2,a2,-484 # ffffffffc0204878 <commands+0x810>
ffffffffc0202a64:	17f00593          	li	a1,383
ffffffffc0202a68:	00002517          	auipc	a0,0x2
ffffffffc0202a6c:	2a050513          	addi	a0,a0,672 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202a70:	9ebfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(p2) == 1);
ffffffffc0202a74:	00002697          	auipc	a3,0x2
ffffffffc0202a78:	55c68693          	addi	a3,a3,1372 # ffffffffc0204fd0 <best_fit_pmm_manager+0x418>
ffffffffc0202a7c:	00002617          	auipc	a2,0x2
ffffffffc0202a80:	dfc60613          	addi	a2,a2,-516 # ffffffffc0204878 <commands+0x810>
ffffffffc0202a84:	17d00593          	li	a1,381
ffffffffc0202a88:	00002517          	auipc	a0,0x2
ffffffffc0202a8c:	28050513          	addi	a0,a0,640 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202a90:	9cbfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(boot_pgdir_va[0] & PTE_U);
ffffffffc0202a94:	00002697          	auipc	a3,0x2
ffffffffc0202a98:	51c68693          	addi	a3,a3,1308 # ffffffffc0204fb0 <best_fit_pmm_manager+0x3f8>
ffffffffc0202a9c:	00002617          	auipc	a2,0x2
ffffffffc0202aa0:	ddc60613          	addi	a2,a2,-548 # ffffffffc0204878 <commands+0x810>
ffffffffc0202aa4:	17c00593          	li	a1,380
ffffffffc0202aa8:	00002517          	auipc	a0,0x2
ffffffffc0202aac:	26050513          	addi	a0,a0,608 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202ab0:	9abfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(*ptep & PTE_W);
ffffffffc0202ab4:	00002697          	auipc	a3,0x2
ffffffffc0202ab8:	4ec68693          	addi	a3,a3,1260 # ffffffffc0204fa0 <best_fit_pmm_manager+0x3e8>
ffffffffc0202abc:	00002617          	auipc	a2,0x2
ffffffffc0202ac0:	dbc60613          	addi	a2,a2,-580 # ffffffffc0204878 <commands+0x810>
ffffffffc0202ac4:	17b00593          	li	a1,379
ffffffffc0202ac8:	00002517          	auipc	a0,0x2
ffffffffc0202acc:	24050513          	addi	a0,a0,576 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202ad0:	98bfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(*ptep & PTE_U);
ffffffffc0202ad4:	00002697          	auipc	a3,0x2
ffffffffc0202ad8:	4bc68693          	addi	a3,a3,1212 # ffffffffc0204f90 <best_fit_pmm_manager+0x3d8>
ffffffffc0202adc:	00002617          	auipc	a2,0x2
ffffffffc0202ae0:	d9c60613          	addi	a2,a2,-612 # ffffffffc0204878 <commands+0x810>
ffffffffc0202ae4:	17a00593          	li	a1,378
ffffffffc0202ae8:	00002517          	auipc	a0,0x2
ffffffffc0202aec:	22050513          	addi	a0,a0,544 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202af0:	96bfd0ef          	jal	ra,ffffffffc020045a <__panic>
        panic("DTB memory info not available");
ffffffffc0202af4:	00002617          	auipc	a2,0x2
ffffffffc0202af8:	23c60613          	addi	a2,a2,572 # ffffffffc0204d30 <best_fit_pmm_manager+0x178>
ffffffffc0202afc:	06500593          	li	a1,101
ffffffffc0202b00:	00002517          	auipc	a0,0x2
ffffffffc0202b04:	20850513          	addi	a0,a0,520 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202b08:	953fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(nr_free_store == nr_free_pages());
ffffffffc0202b0c:	00002697          	auipc	a3,0x2
ffffffffc0202b10:	59c68693          	addi	a3,a3,1436 # ffffffffc02050a8 <best_fit_pmm_manager+0x4f0>
ffffffffc0202b14:	00002617          	auipc	a2,0x2
ffffffffc0202b18:	d6460613          	addi	a2,a2,-668 # ffffffffc0204878 <commands+0x810>
ffffffffc0202b1c:	1c000593          	li	a1,448
ffffffffc0202b20:	00002517          	auipc	a0,0x2
ffffffffc0202b24:	1e850513          	addi	a0,a0,488 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202b28:	933fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((ptep = get_pte(boot_pgdir_va, PGSIZE, 0)) != NULL);
ffffffffc0202b2c:	00002697          	auipc	a3,0x2
ffffffffc0202b30:	42c68693          	addi	a3,a3,1068 # ffffffffc0204f58 <best_fit_pmm_manager+0x3a0>
ffffffffc0202b34:	00002617          	auipc	a2,0x2
ffffffffc0202b38:	d4460613          	addi	a2,a2,-700 # ffffffffc0204878 <commands+0x810>
ffffffffc0202b3c:	17900593          	li	a1,377
ffffffffc0202b40:	00002517          	auipc	a0,0x2
ffffffffc0202b44:	1c850513          	addi	a0,a0,456 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202b48:	913fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_insert(boot_pgdir_va, p2, PGSIZE, PTE_U | PTE_W) == 0);
ffffffffc0202b4c:	00002697          	auipc	a3,0x2
ffffffffc0202b50:	3cc68693          	addi	a3,a3,972 # ffffffffc0204f18 <best_fit_pmm_manager+0x360>
ffffffffc0202b54:	00002617          	auipc	a2,0x2
ffffffffc0202b58:	d2460613          	addi	a2,a2,-732 # ffffffffc0204878 <commands+0x810>
ffffffffc0202b5c:	17800593          	li	a1,376
ffffffffc0202b60:	00002517          	auipc	a0,0x2
ffffffffc0202b64:	1a850513          	addi	a0,a0,424 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202b68:	8f3fd0ef          	jal	ra,ffffffffc020045a <__panic>
    ptep = (pte_t *)KADDR(PDE_ADDR(ptep[0])) + 1;
ffffffffc0202b6c:	86d6                	mv	a3,s5
ffffffffc0202b6e:	00002617          	auipc	a2,0x2
ffffffffc0202b72:	08260613          	addi	a2,a2,130 # ffffffffc0204bf0 <best_fit_pmm_manager+0x38>
ffffffffc0202b76:	17400593          	li	a1,372
ffffffffc0202b7a:	00002517          	auipc	a0,0x2
ffffffffc0202b7e:	18e50513          	addi	a0,a0,398 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202b82:	8d9fd0ef          	jal	ra,ffffffffc020045a <__panic>
    ptep = (pte_t *)KADDR(PDE_ADDR(boot_pgdir_va[0]));
ffffffffc0202b86:	00002617          	auipc	a2,0x2
ffffffffc0202b8a:	06a60613          	addi	a2,a2,106 # ffffffffc0204bf0 <best_fit_pmm_manager+0x38>
ffffffffc0202b8e:	17300593          	li	a1,371
ffffffffc0202b92:	00002517          	auipc	a0,0x2
ffffffffc0202b96:	17650513          	addi	a0,a0,374 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202b9a:	8c1fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(p1) == 1);
ffffffffc0202b9e:	00002697          	auipc	a3,0x2
ffffffffc0202ba2:	33268693          	addi	a3,a3,818 # ffffffffc0204ed0 <best_fit_pmm_manager+0x318>
ffffffffc0202ba6:	00002617          	auipc	a2,0x2
ffffffffc0202baa:	cd260613          	addi	a2,a2,-814 # ffffffffc0204878 <commands+0x810>
ffffffffc0202bae:	17100593          	li	a1,369
ffffffffc0202bb2:	00002517          	auipc	a0,0x2
ffffffffc0202bb6:	15650513          	addi	a0,a0,342 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202bba:	8a1fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(pte2page(*ptep) == p1);
ffffffffc0202bbe:	00002697          	auipc	a3,0x2
ffffffffc0202bc2:	2fa68693          	addi	a3,a3,762 # ffffffffc0204eb8 <best_fit_pmm_manager+0x300>
ffffffffc0202bc6:	00002617          	auipc	a2,0x2
ffffffffc0202bca:	cb260613          	addi	a2,a2,-846 # ffffffffc0204878 <commands+0x810>
ffffffffc0202bce:	17000593          	li	a1,368
ffffffffc0202bd2:	00002517          	auipc	a0,0x2
ffffffffc0202bd6:	13650513          	addi	a0,a0,310 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202bda:	881fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(strlen((const char *)0x100) == 0);
ffffffffc0202bde:	00002697          	auipc	a3,0x2
ffffffffc0202be2:	68a68693          	addi	a3,a3,1674 # ffffffffc0205268 <best_fit_pmm_manager+0x6b0>
ffffffffc0202be6:	00002617          	auipc	a2,0x2
ffffffffc0202bea:	c9260613          	addi	a2,a2,-878 # ffffffffc0204878 <commands+0x810>
ffffffffc0202bee:	1b700593          	li	a1,439
ffffffffc0202bf2:	00002517          	auipc	a0,0x2
ffffffffc0202bf6:	11650513          	addi	a0,a0,278 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202bfa:	861fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(strcmp((void *)0x100, (void *)(0x100 + PGSIZE)) == 0);
ffffffffc0202bfe:	00002697          	auipc	a3,0x2
ffffffffc0202c02:	63268693          	addi	a3,a3,1586 # ffffffffc0205230 <best_fit_pmm_manager+0x678>
ffffffffc0202c06:	00002617          	auipc	a2,0x2
ffffffffc0202c0a:	c7260613          	addi	a2,a2,-910 # ffffffffc0204878 <commands+0x810>
ffffffffc0202c0e:	1b400593          	li	a1,436
ffffffffc0202c12:	00002517          	auipc	a0,0x2
ffffffffc0202c16:	0f650513          	addi	a0,a0,246 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202c1a:	841fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_ref(p) == 2);
ffffffffc0202c1e:	00002697          	auipc	a3,0x2
ffffffffc0202c22:	5e268693          	addi	a3,a3,1506 # ffffffffc0205200 <best_fit_pmm_manager+0x648>
ffffffffc0202c26:	00002617          	auipc	a2,0x2
ffffffffc0202c2a:	c5260613          	addi	a2,a2,-942 # ffffffffc0204878 <commands+0x810>
ffffffffc0202c2e:	1b000593          	li	a1,432
ffffffffc0202c32:	00002517          	auipc	a0,0x2
ffffffffc0202c36:	0d650513          	addi	a0,a0,214 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202c3a:	821fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_insert(boot_pgdir_va, p, 0x100 + PGSIZE, PTE_W | PTE_R) == 0);
ffffffffc0202c3e:	00002697          	auipc	a3,0x2
ffffffffc0202c42:	57a68693          	addi	a3,a3,1402 # ffffffffc02051b8 <best_fit_pmm_manager+0x600>
ffffffffc0202c46:	00002617          	auipc	a2,0x2
ffffffffc0202c4a:	c3260613          	addi	a2,a2,-974 # ffffffffc0204878 <commands+0x810>
ffffffffc0202c4e:	1af00593          	li	a1,431
ffffffffc0202c52:	00002517          	auipc	a0,0x2
ffffffffc0202c56:	0b650513          	addi	a0,a0,182 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202c5a:	801fd0ef          	jal	ra,ffffffffc020045a <__panic>
    boot_pgdir_pa = PADDR(boot_pgdir_va);
ffffffffc0202c5e:	00002617          	auipc	a2,0x2
ffffffffc0202c62:	03a60613          	addi	a2,a2,58 # ffffffffc0204c98 <best_fit_pmm_manager+0xe0>
ffffffffc0202c66:	0cc00593          	li	a1,204
ffffffffc0202c6a:	00002517          	auipc	a0,0x2
ffffffffc0202c6e:	09e50513          	addi	a0,a0,158 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202c72:	fe8fd0ef          	jal	ra,ffffffffc020045a <__panic>
    uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * (npage - nbase));
ffffffffc0202c76:	00002617          	auipc	a2,0x2
ffffffffc0202c7a:	02260613          	addi	a2,a2,34 # ffffffffc0204c98 <best_fit_pmm_manager+0xe0>
ffffffffc0202c7e:	08100593          	li	a1,129
ffffffffc0202c82:	00002517          	auipc	a0,0x2
ffffffffc0202c86:	08650513          	addi	a0,a0,134 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202c8a:	fd0fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert((ptep = get_pte(boot_pgdir_va, 0x0, 0)) != NULL);
ffffffffc0202c8e:	00002697          	auipc	a3,0x2
ffffffffc0202c92:	1fa68693          	addi	a3,a3,506 # ffffffffc0204e88 <best_fit_pmm_manager+0x2d0>
ffffffffc0202c96:	00002617          	auipc	a2,0x2
ffffffffc0202c9a:	be260613          	addi	a2,a2,-1054 # ffffffffc0204878 <commands+0x810>
ffffffffc0202c9e:	16f00593          	li	a1,367
ffffffffc0202ca2:	00002517          	auipc	a0,0x2
ffffffffc0202ca6:	06650513          	addi	a0,a0,102 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202caa:	fb0fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(page_insert(boot_pgdir_va, p1, 0x0, 0) == 0);
ffffffffc0202cae:	00002697          	auipc	a3,0x2
ffffffffc0202cb2:	1aa68693          	addi	a3,a3,426 # ffffffffc0204e58 <best_fit_pmm_manager+0x2a0>
ffffffffc0202cb6:	00002617          	auipc	a2,0x2
ffffffffc0202cba:	bc260613          	addi	a2,a2,-1086 # ffffffffc0204878 <commands+0x810>
ffffffffc0202cbe:	16c00593          	li	a1,364
ffffffffc0202cc2:	00002517          	auipc	a0,0x2
ffffffffc0202cc6:	04650513          	addi	a0,a0,70 # ffffffffc0204d08 <best_fit_pmm_manager+0x150>
ffffffffc0202cca:	f90fd0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0202cce <check_vma_overlap.part.0>:
    return vma;
}

// check_vma_overlap - check if vma1 overlaps vma2 ?
static inline void
check_vma_overlap(struct vma_struct *prev, struct vma_struct *next)
ffffffffc0202cce:	1141                	addi	sp,sp,-16
{
    assert(prev->vm_start < prev->vm_end);
    assert(prev->vm_end <= next->vm_start);
    assert(next->vm_start < next->vm_end);
ffffffffc0202cd0:	00002697          	auipc	a3,0x2
ffffffffc0202cd4:	5e068693          	addi	a3,a3,1504 # ffffffffc02052b0 <best_fit_pmm_manager+0x6f8>
ffffffffc0202cd8:	00002617          	auipc	a2,0x2
ffffffffc0202cdc:	ba060613          	addi	a2,a2,-1120 # ffffffffc0204878 <commands+0x810>
ffffffffc0202ce0:	08800593          	li	a1,136
ffffffffc0202ce4:	00002517          	auipc	a0,0x2
ffffffffc0202ce8:	5ec50513          	addi	a0,a0,1516 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
check_vma_overlap(struct vma_struct *prev, struct vma_struct *next)
ffffffffc0202cec:	e406                	sd	ra,8(sp)
    assert(next->vm_start < next->vm_end);
ffffffffc0202cee:	f6cfd0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0202cf2 <find_vma>:
{
ffffffffc0202cf2:	86aa                	mv	a3,a0
    if (mm != NULL)
ffffffffc0202cf4:	c505                	beqz	a0,ffffffffc0202d1c <find_vma+0x2a>
        vma = mm->mmap_cache;
ffffffffc0202cf6:	6908                	ld	a0,16(a0)
        if (!(vma != NULL && vma->vm_start <= addr && vma->vm_end > addr))
ffffffffc0202cf8:	c501                	beqz	a0,ffffffffc0202d00 <find_vma+0xe>
ffffffffc0202cfa:	651c                	ld	a5,8(a0)
ffffffffc0202cfc:	02f5f263          	bgeu	a1,a5,ffffffffc0202d20 <find_vma+0x2e>
    return listelm->next;
ffffffffc0202d00:	669c                	ld	a5,8(a3)
            while ((le = list_next(le)) != list)
ffffffffc0202d02:	00f68d63          	beq	a3,a5,ffffffffc0202d1c <find_vma+0x2a>
                if (vma->vm_start <= addr && addr < vma->vm_end)
ffffffffc0202d06:	fe87b703          	ld	a4,-24(a5) # ffffffffc7ffffe8 <end+0x7df2afc>
ffffffffc0202d0a:	00e5e663          	bltu	a1,a4,ffffffffc0202d16 <find_vma+0x24>
ffffffffc0202d0e:	ff07b703          	ld	a4,-16(a5)
ffffffffc0202d12:	00e5ec63          	bltu	a1,a4,ffffffffc0202d2a <find_vma+0x38>
ffffffffc0202d16:	679c                	ld	a5,8(a5)
            while ((le = list_next(le)) != list)
ffffffffc0202d18:	fef697e3          	bne	a3,a5,ffffffffc0202d06 <find_vma+0x14>
    struct vma_struct *vma = NULL;
ffffffffc0202d1c:	4501                	li	a0,0
}
ffffffffc0202d1e:	8082                	ret
        if (!(vma != NULL && vma->vm_start <= addr && vma->vm_end > addr))
ffffffffc0202d20:	691c                	ld	a5,16(a0)
ffffffffc0202d22:	fcf5ffe3          	bgeu	a1,a5,ffffffffc0202d00 <find_vma+0xe>
            mm->mmap_cache = vma;
ffffffffc0202d26:	ea88                	sd	a0,16(a3)
ffffffffc0202d28:	8082                	ret
                vma = le2vma(le, list_link);
ffffffffc0202d2a:	fe078513          	addi	a0,a5,-32
            mm->mmap_cache = vma;
ffffffffc0202d2e:	ea88                	sd	a0,16(a3)
ffffffffc0202d30:	8082                	ret

ffffffffc0202d32 <insert_vma_struct>:
}

// insert_vma_struct -insert vma in mm's list link
void insert_vma_struct(struct mm_struct *mm, struct vma_struct *vma)
{
    assert(vma->vm_start < vma->vm_end);
ffffffffc0202d32:	6590                	ld	a2,8(a1)
ffffffffc0202d34:	0105b803          	ld	a6,16(a1)
{
ffffffffc0202d38:	1141                	addi	sp,sp,-16
ffffffffc0202d3a:	e406                	sd	ra,8(sp)
ffffffffc0202d3c:	87aa                	mv	a5,a0
    assert(vma->vm_start < vma->vm_end);
ffffffffc0202d3e:	01066763          	bltu	a2,a6,ffffffffc0202d4c <insert_vma_struct+0x1a>
ffffffffc0202d42:	a085                	j	ffffffffc0202da2 <insert_vma_struct+0x70>

    list_entry_t *le = list;
    while ((le = list_next(le)) != list)
    {
        struct vma_struct *mmap_prev = le2vma(le, list_link);
        if (mmap_prev->vm_start > vma->vm_start)
ffffffffc0202d44:	fe87b703          	ld	a4,-24(a5)
ffffffffc0202d48:	04e66863          	bltu	a2,a4,ffffffffc0202d98 <insert_vma_struct+0x66>
ffffffffc0202d4c:	86be                	mv	a3,a5
ffffffffc0202d4e:	679c                	ld	a5,8(a5)
    while ((le = list_next(le)) != list)
ffffffffc0202d50:	fef51ae3          	bne	a0,a5,ffffffffc0202d44 <insert_vma_struct+0x12>
    }

    le_next = list_next(le_prev);

    /* check overlap */
    if (le_prev != list)
ffffffffc0202d54:	02a68463          	beq	a3,a0,ffffffffc0202d7c <insert_vma_struct+0x4a>
    {
        check_vma_overlap(le2vma(le_prev, list_link), vma);
ffffffffc0202d58:	ff06b703          	ld	a4,-16(a3)
    assert(prev->vm_start < prev->vm_end);
ffffffffc0202d5c:	fe86b883          	ld	a7,-24(a3)
ffffffffc0202d60:	08e8f163          	bgeu	a7,a4,ffffffffc0202de2 <insert_vma_struct+0xb0>
    assert(prev->vm_end <= next->vm_start);
ffffffffc0202d64:	04e66f63          	bltu	a2,a4,ffffffffc0202dc2 <insert_vma_struct+0x90>
    }
    if (le_next != list)
ffffffffc0202d68:	00f50a63          	beq	a0,a5,ffffffffc0202d7c <insert_vma_struct+0x4a>
        if (mmap_prev->vm_start > vma->vm_start)
ffffffffc0202d6c:	fe87b703          	ld	a4,-24(a5)
    assert(prev->vm_end <= next->vm_start);
ffffffffc0202d70:	05076963          	bltu	a4,a6,ffffffffc0202dc2 <insert_vma_struct+0x90>
    assert(next->vm_start < next->vm_end);
ffffffffc0202d74:	ff07b603          	ld	a2,-16(a5)
ffffffffc0202d78:	02c77363          	bgeu	a4,a2,ffffffffc0202d9e <insert_vma_struct+0x6c>
    }

    vma->vm_mm = mm;
    list_add_after(le_prev, &(vma->list_link));

    mm->map_count++;
ffffffffc0202d7c:	5118                	lw	a4,32(a0)
    vma->vm_mm = mm;
ffffffffc0202d7e:	e188                	sd	a0,0(a1)
    list_add_after(le_prev, &(vma->list_link));
ffffffffc0202d80:	02058613          	addi	a2,a1,32
    prev->next = next->prev = elm;
ffffffffc0202d84:	e390                	sd	a2,0(a5)
ffffffffc0202d86:	e690                	sd	a2,8(a3)
}
ffffffffc0202d88:	60a2                	ld	ra,8(sp)
    elm->next = next;
ffffffffc0202d8a:	f59c                	sd	a5,40(a1)
    elm->prev = prev;
ffffffffc0202d8c:	f194                	sd	a3,32(a1)
    mm->map_count++;
ffffffffc0202d8e:	0017079b          	addiw	a5,a4,1
ffffffffc0202d92:	d11c                	sw	a5,32(a0)
}
ffffffffc0202d94:	0141                	addi	sp,sp,16
ffffffffc0202d96:	8082                	ret
    if (le_prev != list)
ffffffffc0202d98:	fca690e3          	bne	a3,a0,ffffffffc0202d58 <insert_vma_struct+0x26>
ffffffffc0202d9c:	bfd1                	j	ffffffffc0202d70 <insert_vma_struct+0x3e>
ffffffffc0202d9e:	f31ff0ef          	jal	ra,ffffffffc0202cce <check_vma_overlap.part.0>
    assert(vma->vm_start < vma->vm_end);
ffffffffc0202da2:	00002697          	auipc	a3,0x2
ffffffffc0202da6:	53e68693          	addi	a3,a3,1342 # ffffffffc02052e0 <best_fit_pmm_manager+0x728>
ffffffffc0202daa:	00002617          	auipc	a2,0x2
ffffffffc0202dae:	ace60613          	addi	a2,a2,-1330 # ffffffffc0204878 <commands+0x810>
ffffffffc0202db2:	08e00593          	li	a1,142
ffffffffc0202db6:	00002517          	auipc	a0,0x2
ffffffffc0202dba:	51a50513          	addi	a0,a0,1306 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0202dbe:	e9cfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(prev->vm_end <= next->vm_start);
ffffffffc0202dc2:	00002697          	auipc	a3,0x2
ffffffffc0202dc6:	55e68693          	addi	a3,a3,1374 # ffffffffc0205320 <best_fit_pmm_manager+0x768>
ffffffffc0202dca:	00002617          	auipc	a2,0x2
ffffffffc0202dce:	aae60613          	addi	a2,a2,-1362 # ffffffffc0204878 <commands+0x810>
ffffffffc0202dd2:	08700593          	li	a1,135
ffffffffc0202dd6:	00002517          	auipc	a0,0x2
ffffffffc0202dda:	4fa50513          	addi	a0,a0,1274 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0202dde:	e7cfd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(prev->vm_start < prev->vm_end);
ffffffffc0202de2:	00002697          	auipc	a3,0x2
ffffffffc0202de6:	51e68693          	addi	a3,a3,1310 # ffffffffc0205300 <best_fit_pmm_manager+0x748>
ffffffffc0202dea:	00002617          	auipc	a2,0x2
ffffffffc0202dee:	a8e60613          	addi	a2,a2,-1394 # ffffffffc0204878 <commands+0x810>
ffffffffc0202df2:	08600593          	li	a1,134
ffffffffc0202df6:	00002517          	auipc	a0,0x2
ffffffffc0202dfa:	4da50513          	addi	a0,a0,1242 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0202dfe:	e5cfd0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0202e02 <vmm_init>:
}

// vmm_init - initialize virtual memory management
//          - now just call check_vmm to check correctness of vmm
void vmm_init(void)
{
ffffffffc0202e02:	7139                	addi	sp,sp,-64
    struct mm_struct *mm = kmalloc(sizeof(struct mm_struct));
ffffffffc0202e04:	03000513          	li	a0,48
{
ffffffffc0202e08:	fc06                	sd	ra,56(sp)
ffffffffc0202e0a:	f822                	sd	s0,48(sp)
ffffffffc0202e0c:	f426                	sd	s1,40(sp)
ffffffffc0202e0e:	f04a                	sd	s2,32(sp)
ffffffffc0202e10:	ec4e                	sd	s3,24(sp)
ffffffffc0202e12:	e852                	sd	s4,16(sp)
ffffffffc0202e14:	e456                	sd	s5,8(sp)
    struct mm_struct *mm = kmalloc(sizeof(struct mm_struct));
ffffffffc0202e16:	bd5fe0ef          	jal	ra,ffffffffc02019ea <kmalloc>
    if (mm != NULL)
ffffffffc0202e1a:	2e050f63          	beqz	a0,ffffffffc0203118 <vmm_init+0x316>
ffffffffc0202e1e:	84aa                	mv	s1,a0
    elm->prev = elm->next = elm;
ffffffffc0202e20:	e508                	sd	a0,8(a0)
ffffffffc0202e22:	e108                	sd	a0,0(a0)
        mm->mmap_cache = NULL;
ffffffffc0202e24:	00053823          	sd	zero,16(a0)
        mm->pgdir = NULL;
ffffffffc0202e28:	00053c23          	sd	zero,24(a0)
        mm->map_count = 0;
ffffffffc0202e2c:	02052023          	sw	zero,32(a0)
        mm->sm_priv = NULL;
ffffffffc0202e30:	02053423          	sd	zero,40(a0)
ffffffffc0202e34:	03200413          	li	s0,50
ffffffffc0202e38:	a811                	j	ffffffffc0202e4c <vmm_init+0x4a>
        vma->vm_start = vm_start;
ffffffffc0202e3a:	e500                	sd	s0,8(a0)
        vma->vm_end = vm_end;
ffffffffc0202e3c:	e91c                	sd	a5,16(a0)
        vma->vm_flags = vm_flags;
ffffffffc0202e3e:	00052c23          	sw	zero,24(a0)
    assert(mm != NULL);

    int step1 = 10, step2 = step1 * 10;

    int i;
    for (i = step1; i >= 1; i--)
ffffffffc0202e42:	146d                	addi	s0,s0,-5
    {
        struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0);
        assert(vma != NULL);
        insert_vma_struct(mm, vma);
ffffffffc0202e44:	8526                	mv	a0,s1
ffffffffc0202e46:	eedff0ef          	jal	ra,ffffffffc0202d32 <insert_vma_struct>
    for (i = step1; i >= 1; i--)
ffffffffc0202e4a:	c80d                	beqz	s0,ffffffffc0202e7c <vmm_init+0x7a>
    struct vma_struct *vma = kmalloc(sizeof(struct vma_struct));
ffffffffc0202e4c:	03000513          	li	a0,48
ffffffffc0202e50:	b9bfe0ef          	jal	ra,ffffffffc02019ea <kmalloc>
ffffffffc0202e54:	85aa                	mv	a1,a0
ffffffffc0202e56:	00240793          	addi	a5,s0,2
    if (vma != NULL)
ffffffffc0202e5a:	f165                	bnez	a0,ffffffffc0202e3a <vmm_init+0x38>
        assert(vma != NULL);
ffffffffc0202e5c:	00002697          	auipc	a3,0x2
ffffffffc0202e60:	65c68693          	addi	a3,a3,1628 # ffffffffc02054b8 <best_fit_pmm_manager+0x900>
ffffffffc0202e64:	00002617          	auipc	a2,0x2
ffffffffc0202e68:	a1460613          	addi	a2,a2,-1516 # ffffffffc0204878 <commands+0x810>
ffffffffc0202e6c:	0da00593          	li	a1,218
ffffffffc0202e70:	00002517          	auipc	a0,0x2
ffffffffc0202e74:	46050513          	addi	a0,a0,1120 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0202e78:	de2fd0ef          	jal	ra,ffffffffc020045a <__panic>
ffffffffc0202e7c:	03700413          	li	s0,55
    }

    for (i = step1 + 1; i <= step2; i++)
ffffffffc0202e80:	1f900913          	li	s2,505
ffffffffc0202e84:	a819                	j	ffffffffc0202e9a <vmm_init+0x98>
        vma->vm_start = vm_start;
ffffffffc0202e86:	e500                	sd	s0,8(a0)
        vma->vm_end = vm_end;
ffffffffc0202e88:	e91c                	sd	a5,16(a0)
        vma->vm_flags = vm_flags;
ffffffffc0202e8a:	00052c23          	sw	zero,24(a0)
    for (i = step1 + 1; i <= step2; i++)
ffffffffc0202e8e:	0415                	addi	s0,s0,5
    {
        struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0);
        assert(vma != NULL);
        insert_vma_struct(mm, vma);
ffffffffc0202e90:	8526                	mv	a0,s1
ffffffffc0202e92:	ea1ff0ef          	jal	ra,ffffffffc0202d32 <insert_vma_struct>
    for (i = step1 + 1; i <= step2; i++)
ffffffffc0202e96:	03240a63          	beq	s0,s2,ffffffffc0202eca <vmm_init+0xc8>
    struct vma_struct *vma = kmalloc(sizeof(struct vma_struct));
ffffffffc0202e9a:	03000513          	li	a0,48
ffffffffc0202e9e:	b4dfe0ef          	jal	ra,ffffffffc02019ea <kmalloc>
ffffffffc0202ea2:	85aa                	mv	a1,a0
ffffffffc0202ea4:	00240793          	addi	a5,s0,2
    if (vma != NULL)
ffffffffc0202ea8:	fd79                	bnez	a0,ffffffffc0202e86 <vmm_init+0x84>
        assert(vma != NULL);
ffffffffc0202eaa:	00002697          	auipc	a3,0x2
ffffffffc0202eae:	60e68693          	addi	a3,a3,1550 # ffffffffc02054b8 <best_fit_pmm_manager+0x900>
ffffffffc0202eb2:	00002617          	auipc	a2,0x2
ffffffffc0202eb6:	9c660613          	addi	a2,a2,-1594 # ffffffffc0204878 <commands+0x810>
ffffffffc0202eba:	0e100593          	li	a1,225
ffffffffc0202ebe:	00002517          	auipc	a0,0x2
ffffffffc0202ec2:	41250513          	addi	a0,a0,1042 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0202ec6:	d94fd0ef          	jal	ra,ffffffffc020045a <__panic>
    return listelm->next;
ffffffffc0202eca:	649c                	ld	a5,8(s1)
ffffffffc0202ecc:	471d                	li	a4,7
    }

    list_entry_t *le = list_next(&(mm->mmap_list));

    for (i = 1; i <= step2; i++)
ffffffffc0202ece:	1fb00593          	li	a1,507
    {
        assert(le != &(mm->mmap_list));
ffffffffc0202ed2:	18f48363          	beq	s1,a5,ffffffffc0203058 <vmm_init+0x256>
        struct vma_struct *mmap = le2vma(le, list_link);
        assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
ffffffffc0202ed6:	fe87b603          	ld	a2,-24(a5)
ffffffffc0202eda:	ffe70693          	addi	a3,a4,-2 # ffe <kern_entry-0xffffffffc01ff002>
ffffffffc0202ede:	10d61d63          	bne	a2,a3,ffffffffc0202ff8 <vmm_init+0x1f6>
ffffffffc0202ee2:	ff07b683          	ld	a3,-16(a5)
ffffffffc0202ee6:	10e69963          	bne	a3,a4,ffffffffc0202ff8 <vmm_init+0x1f6>
    for (i = 1; i <= step2; i++)
ffffffffc0202eea:	0715                	addi	a4,a4,5
ffffffffc0202eec:	679c                	ld	a5,8(a5)
ffffffffc0202eee:	feb712e3          	bne	a4,a1,ffffffffc0202ed2 <vmm_init+0xd0>
ffffffffc0202ef2:	4a1d                	li	s4,7
ffffffffc0202ef4:	4415                	li	s0,5
        le = list_next(le);
    }

    for (i = 5; i <= 5 * step2; i += 5)
ffffffffc0202ef6:	1f900a93          	li	s5,505
    {
        struct vma_struct *vma1 = find_vma(mm, i);
ffffffffc0202efa:	85a2                	mv	a1,s0
ffffffffc0202efc:	8526                	mv	a0,s1
ffffffffc0202efe:	df5ff0ef          	jal	ra,ffffffffc0202cf2 <find_vma>
ffffffffc0202f02:	892a                	mv	s2,a0
        assert(vma1 != NULL);
ffffffffc0202f04:	18050a63          	beqz	a0,ffffffffc0203098 <vmm_init+0x296>
        struct vma_struct *vma2 = find_vma(mm, i + 1);
ffffffffc0202f08:	00140593          	addi	a1,s0,1
ffffffffc0202f0c:	8526                	mv	a0,s1
ffffffffc0202f0e:	de5ff0ef          	jal	ra,ffffffffc0202cf2 <find_vma>
ffffffffc0202f12:	89aa                	mv	s3,a0
        assert(vma2 != NULL);
ffffffffc0202f14:	16050263          	beqz	a0,ffffffffc0203078 <vmm_init+0x276>
        struct vma_struct *vma3 = find_vma(mm, i + 2);
ffffffffc0202f18:	85d2                	mv	a1,s4
ffffffffc0202f1a:	8526                	mv	a0,s1
ffffffffc0202f1c:	dd7ff0ef          	jal	ra,ffffffffc0202cf2 <find_vma>
        assert(vma3 == NULL);
ffffffffc0202f20:	18051c63          	bnez	a0,ffffffffc02030b8 <vmm_init+0x2b6>
        struct vma_struct *vma4 = find_vma(mm, i + 3);
ffffffffc0202f24:	00340593          	addi	a1,s0,3
ffffffffc0202f28:	8526                	mv	a0,s1
ffffffffc0202f2a:	dc9ff0ef          	jal	ra,ffffffffc0202cf2 <find_vma>
        assert(vma4 == NULL);
ffffffffc0202f2e:	1c051563          	bnez	a0,ffffffffc02030f8 <vmm_init+0x2f6>
        struct vma_struct *vma5 = find_vma(mm, i + 4);
ffffffffc0202f32:	00440593          	addi	a1,s0,4
ffffffffc0202f36:	8526                	mv	a0,s1
ffffffffc0202f38:	dbbff0ef          	jal	ra,ffffffffc0202cf2 <find_vma>
        assert(vma5 == NULL);
ffffffffc0202f3c:	18051e63          	bnez	a0,ffffffffc02030d8 <vmm_init+0x2d6>

        assert(vma1->vm_start == i && vma1->vm_end == i + 2);
ffffffffc0202f40:	00893783          	ld	a5,8(s2)
ffffffffc0202f44:	0c879a63          	bne	a5,s0,ffffffffc0203018 <vmm_init+0x216>
ffffffffc0202f48:	01093783          	ld	a5,16(s2)
ffffffffc0202f4c:	0d479663          	bne	a5,s4,ffffffffc0203018 <vmm_init+0x216>
        assert(vma2->vm_start == i && vma2->vm_end == i + 2);
ffffffffc0202f50:	0089b783          	ld	a5,8(s3)
ffffffffc0202f54:	0e879263          	bne	a5,s0,ffffffffc0203038 <vmm_init+0x236>
ffffffffc0202f58:	0109b783          	ld	a5,16(s3)
ffffffffc0202f5c:	0d479e63          	bne	a5,s4,ffffffffc0203038 <vmm_init+0x236>
    for (i = 5; i <= 5 * step2; i += 5)
ffffffffc0202f60:	0415                	addi	s0,s0,5
ffffffffc0202f62:	0a15                	addi	s4,s4,5
ffffffffc0202f64:	f9541be3          	bne	s0,s5,ffffffffc0202efa <vmm_init+0xf8>
ffffffffc0202f68:	4411                	li	s0,4
    }

    for (i = 4; i >= 0; i--)
ffffffffc0202f6a:	597d                	li	s2,-1
    {
        struct vma_struct *vma_below_5 = find_vma(mm, i);
ffffffffc0202f6c:	85a2                	mv	a1,s0
ffffffffc0202f6e:	8526                	mv	a0,s1
ffffffffc0202f70:	d83ff0ef          	jal	ra,ffffffffc0202cf2 <find_vma>
ffffffffc0202f74:	0004059b          	sext.w	a1,s0
        if (vma_below_5 != NULL)
ffffffffc0202f78:	c90d                	beqz	a0,ffffffffc0202faa <vmm_init+0x1a8>
        {
            cprintf("vma_below_5: i %x, start %x, end %x\n", i, vma_below_5->vm_start, vma_below_5->vm_end);
ffffffffc0202f7a:	6914                	ld	a3,16(a0)
ffffffffc0202f7c:	6510                	ld	a2,8(a0)
ffffffffc0202f7e:	00002517          	auipc	a0,0x2
ffffffffc0202f82:	4c250513          	addi	a0,a0,1218 # ffffffffc0205440 <best_fit_pmm_manager+0x888>
ffffffffc0202f86:	a0efd0ef          	jal	ra,ffffffffc0200194 <cprintf>
        }
        assert(vma_below_5 == NULL);
ffffffffc0202f8a:	00002697          	auipc	a3,0x2
ffffffffc0202f8e:	4de68693          	addi	a3,a3,1246 # ffffffffc0205468 <best_fit_pmm_manager+0x8b0>
ffffffffc0202f92:	00002617          	auipc	a2,0x2
ffffffffc0202f96:	8e660613          	addi	a2,a2,-1818 # ffffffffc0204878 <commands+0x810>
ffffffffc0202f9a:	10700593          	li	a1,263
ffffffffc0202f9e:	00002517          	auipc	a0,0x2
ffffffffc0202fa2:	33250513          	addi	a0,a0,818 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0202fa6:	cb4fd0ef          	jal	ra,ffffffffc020045a <__panic>
    for (i = 4; i >= 0; i--)
ffffffffc0202faa:	147d                	addi	s0,s0,-1
ffffffffc0202fac:	fd2410e3          	bne	s0,s2,ffffffffc0202f6c <vmm_init+0x16a>
ffffffffc0202fb0:	6488                	ld	a0,8(s1)
    while ((le = list_next(list)) != list)
ffffffffc0202fb2:	00a48c63          	beq	s1,a0,ffffffffc0202fca <vmm_init+0x1c8>
    __list_del(listelm->prev, listelm->next);
ffffffffc0202fb6:	6118                	ld	a4,0(a0)
ffffffffc0202fb8:	651c                	ld	a5,8(a0)
        kfree(le2vma(le, list_link)); // kfree vma
ffffffffc0202fba:	1501                	addi	a0,a0,-32
    prev->next = next;
ffffffffc0202fbc:	e71c                	sd	a5,8(a4)
    next->prev = prev;
ffffffffc0202fbe:	e398                	sd	a4,0(a5)
ffffffffc0202fc0:	adbfe0ef          	jal	ra,ffffffffc0201a9a <kfree>
    return listelm->next;
ffffffffc0202fc4:	6488                	ld	a0,8(s1)
    while ((le = list_next(list)) != list)
ffffffffc0202fc6:	fea498e3          	bne	s1,a0,ffffffffc0202fb6 <vmm_init+0x1b4>
    kfree(mm); // kfree mm
ffffffffc0202fca:	8526                	mv	a0,s1
ffffffffc0202fcc:	acffe0ef          	jal	ra,ffffffffc0201a9a <kfree>
    }

    mm_destroy(mm);

    cprintf("check_vma_struct() succeeded!\n");
ffffffffc0202fd0:	00002517          	auipc	a0,0x2
ffffffffc0202fd4:	4b050513          	addi	a0,a0,1200 # ffffffffc0205480 <best_fit_pmm_manager+0x8c8>
ffffffffc0202fd8:	9bcfd0ef          	jal	ra,ffffffffc0200194 <cprintf>
}
ffffffffc0202fdc:	7442                	ld	s0,48(sp)
ffffffffc0202fde:	70e2                	ld	ra,56(sp)
ffffffffc0202fe0:	74a2                	ld	s1,40(sp)
ffffffffc0202fe2:	7902                	ld	s2,32(sp)
ffffffffc0202fe4:	69e2                	ld	s3,24(sp)
ffffffffc0202fe6:	6a42                	ld	s4,16(sp)
ffffffffc0202fe8:	6aa2                	ld	s5,8(sp)
    cprintf("check_vmm() succeeded.\n");
ffffffffc0202fea:	00002517          	auipc	a0,0x2
ffffffffc0202fee:	4b650513          	addi	a0,a0,1206 # ffffffffc02054a0 <best_fit_pmm_manager+0x8e8>
}
ffffffffc0202ff2:	6121                	addi	sp,sp,64
    cprintf("check_vmm() succeeded.\n");
ffffffffc0202ff4:	9a0fd06f          	j	ffffffffc0200194 <cprintf>
        assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
ffffffffc0202ff8:	00002697          	auipc	a3,0x2
ffffffffc0202ffc:	36068693          	addi	a3,a3,864 # ffffffffc0205358 <best_fit_pmm_manager+0x7a0>
ffffffffc0203000:	00002617          	auipc	a2,0x2
ffffffffc0203004:	87860613          	addi	a2,a2,-1928 # ffffffffc0204878 <commands+0x810>
ffffffffc0203008:	0eb00593          	li	a1,235
ffffffffc020300c:	00002517          	auipc	a0,0x2
ffffffffc0203010:	2c450513          	addi	a0,a0,708 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0203014:	c46fd0ef          	jal	ra,ffffffffc020045a <__panic>
        assert(vma1->vm_start == i && vma1->vm_end == i + 2);
ffffffffc0203018:	00002697          	auipc	a3,0x2
ffffffffc020301c:	3c868693          	addi	a3,a3,968 # ffffffffc02053e0 <best_fit_pmm_manager+0x828>
ffffffffc0203020:	00002617          	auipc	a2,0x2
ffffffffc0203024:	85860613          	addi	a2,a2,-1960 # ffffffffc0204878 <commands+0x810>
ffffffffc0203028:	0fc00593          	li	a1,252
ffffffffc020302c:	00002517          	auipc	a0,0x2
ffffffffc0203030:	2a450513          	addi	a0,a0,676 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0203034:	c26fd0ef          	jal	ra,ffffffffc020045a <__panic>
        assert(vma2->vm_start == i && vma2->vm_end == i + 2);
ffffffffc0203038:	00002697          	auipc	a3,0x2
ffffffffc020303c:	3d868693          	addi	a3,a3,984 # ffffffffc0205410 <best_fit_pmm_manager+0x858>
ffffffffc0203040:	00002617          	auipc	a2,0x2
ffffffffc0203044:	83860613          	addi	a2,a2,-1992 # ffffffffc0204878 <commands+0x810>
ffffffffc0203048:	0fd00593          	li	a1,253
ffffffffc020304c:	00002517          	auipc	a0,0x2
ffffffffc0203050:	28450513          	addi	a0,a0,644 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0203054:	c06fd0ef          	jal	ra,ffffffffc020045a <__panic>
        assert(le != &(mm->mmap_list));
ffffffffc0203058:	00002697          	auipc	a3,0x2
ffffffffc020305c:	2e868693          	addi	a3,a3,744 # ffffffffc0205340 <best_fit_pmm_manager+0x788>
ffffffffc0203060:	00002617          	auipc	a2,0x2
ffffffffc0203064:	81860613          	addi	a2,a2,-2024 # ffffffffc0204878 <commands+0x810>
ffffffffc0203068:	0e900593          	li	a1,233
ffffffffc020306c:	00002517          	auipc	a0,0x2
ffffffffc0203070:	26450513          	addi	a0,a0,612 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0203074:	be6fd0ef          	jal	ra,ffffffffc020045a <__panic>
        assert(vma2 != NULL);
ffffffffc0203078:	00002697          	auipc	a3,0x2
ffffffffc020307c:	32868693          	addi	a3,a3,808 # ffffffffc02053a0 <best_fit_pmm_manager+0x7e8>
ffffffffc0203080:	00001617          	auipc	a2,0x1
ffffffffc0203084:	7f860613          	addi	a2,a2,2040 # ffffffffc0204878 <commands+0x810>
ffffffffc0203088:	0f400593          	li	a1,244
ffffffffc020308c:	00002517          	auipc	a0,0x2
ffffffffc0203090:	24450513          	addi	a0,a0,580 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0203094:	bc6fd0ef          	jal	ra,ffffffffc020045a <__panic>
        assert(vma1 != NULL);
ffffffffc0203098:	00002697          	auipc	a3,0x2
ffffffffc020309c:	2f868693          	addi	a3,a3,760 # ffffffffc0205390 <best_fit_pmm_manager+0x7d8>
ffffffffc02030a0:	00001617          	auipc	a2,0x1
ffffffffc02030a4:	7d860613          	addi	a2,a2,2008 # ffffffffc0204878 <commands+0x810>
ffffffffc02030a8:	0f200593          	li	a1,242
ffffffffc02030ac:	00002517          	auipc	a0,0x2
ffffffffc02030b0:	22450513          	addi	a0,a0,548 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc02030b4:	ba6fd0ef          	jal	ra,ffffffffc020045a <__panic>
        assert(vma3 == NULL);
ffffffffc02030b8:	00002697          	auipc	a3,0x2
ffffffffc02030bc:	2f868693          	addi	a3,a3,760 # ffffffffc02053b0 <best_fit_pmm_manager+0x7f8>
ffffffffc02030c0:	00001617          	auipc	a2,0x1
ffffffffc02030c4:	7b860613          	addi	a2,a2,1976 # ffffffffc0204878 <commands+0x810>
ffffffffc02030c8:	0f600593          	li	a1,246
ffffffffc02030cc:	00002517          	auipc	a0,0x2
ffffffffc02030d0:	20450513          	addi	a0,a0,516 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc02030d4:	b86fd0ef          	jal	ra,ffffffffc020045a <__panic>
        assert(vma5 == NULL);
ffffffffc02030d8:	00002697          	auipc	a3,0x2
ffffffffc02030dc:	2f868693          	addi	a3,a3,760 # ffffffffc02053d0 <best_fit_pmm_manager+0x818>
ffffffffc02030e0:	00001617          	auipc	a2,0x1
ffffffffc02030e4:	79860613          	addi	a2,a2,1944 # ffffffffc0204878 <commands+0x810>
ffffffffc02030e8:	0fa00593          	li	a1,250
ffffffffc02030ec:	00002517          	auipc	a0,0x2
ffffffffc02030f0:	1e450513          	addi	a0,a0,484 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc02030f4:	b66fd0ef          	jal	ra,ffffffffc020045a <__panic>
        assert(vma4 == NULL);
ffffffffc02030f8:	00002697          	auipc	a3,0x2
ffffffffc02030fc:	2c868693          	addi	a3,a3,712 # ffffffffc02053c0 <best_fit_pmm_manager+0x808>
ffffffffc0203100:	00001617          	auipc	a2,0x1
ffffffffc0203104:	77860613          	addi	a2,a2,1912 # ffffffffc0204878 <commands+0x810>
ffffffffc0203108:	0f800593          	li	a1,248
ffffffffc020310c:	00002517          	auipc	a0,0x2
ffffffffc0203110:	1c450513          	addi	a0,a0,452 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0203114:	b46fd0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(mm != NULL);
ffffffffc0203118:	00002697          	auipc	a3,0x2
ffffffffc020311c:	3b068693          	addi	a3,a3,944 # ffffffffc02054c8 <best_fit_pmm_manager+0x910>
ffffffffc0203120:	00001617          	auipc	a2,0x1
ffffffffc0203124:	75860613          	addi	a2,a2,1880 # ffffffffc0204878 <commands+0x810>
ffffffffc0203128:	0d200593          	li	a1,210
ffffffffc020312c:	00002517          	auipc	a0,0x2
ffffffffc0203130:	1a450513          	addi	a0,a0,420 # ffffffffc02052d0 <best_fit_pmm_manager+0x718>
ffffffffc0203134:	b26fd0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0203138 <kernel_thread_entry>:
.text
.globl kernel_thread_entry
kernel_thread_entry:        # void kernel_thread(void)
	move a0, s1
ffffffffc0203138:	8526                	mv	a0,s1
	jalr s0
ffffffffc020313a:	9402                	jalr	s0

	jal do_exit
ffffffffc020313c:	414000ef          	jal	ra,ffffffffc0203550 <do_exit>

ffffffffc0203140 <alloc_proc>:
void switch_to(struct context *from, struct context *to);

// alloc_proc - alloc a proc_struct and init all fields of proc_struct
static struct proc_struct *
alloc_proc(void)
{
ffffffffc0203140:	1141                	addi	sp,sp,-16
    struct proc_struct *proc = kmalloc(sizeof(struct proc_struct));
ffffffffc0203142:	0e800513          	li	a0,232
{
ffffffffc0203146:	e022                	sd	s0,0(sp)
ffffffffc0203148:	e406                	sd	ra,8(sp)
    struct proc_struct *proc = kmalloc(sizeof(struct proc_struct));
ffffffffc020314a:	8a1fe0ef          	jal	ra,ffffffffc02019ea <kmalloc>
ffffffffc020314e:	842a                	mv	s0,a0
    if (proc != NULL)
ffffffffc0203150:	c521                	beqz	a0,ffffffffc0203198 <alloc_proc+0x58>
         *       struct trapframe *tf;                       // Trap frame for current interrupt
         *       uintptr_t pgdir;                            // the base addr of Page Directroy Table(PDT)
         *       uint32_t flags;                             // Process flag
         *       char name[PROC_NAME_LEN + 1];               // Process name
         */
        proc->state = PROC_UNINIT;                           // 进程状态：未初始化
ffffffffc0203152:	57fd                	li	a5,-1
ffffffffc0203154:	1782                	slli	a5,a5,0x20
ffffffffc0203156:	e11c                	sd	a5,0(a0)
        proc->runs = 0;                                      // 运行次数：0
        proc->kstack = 0;                                    // 内核栈：0表示未分配
        proc->need_resched = 0;                              // 不需要重新调度
        proc->parent = NULL;                                 // 父进程：空
        proc->mm = NULL;                                     // 内存管理结构：空
        memset(&(proc->context), 0, sizeof(struct context)); // 上下文清零
ffffffffc0203158:	07000613          	li	a2,112
ffffffffc020315c:	4581                	li	a1,0
        proc->runs = 0;                                      // 运行次数：0
ffffffffc020315e:	00052423          	sw	zero,8(a0)
        proc->kstack = 0;                                    // 内核栈：0表示未分配
ffffffffc0203162:	00053823          	sd	zero,16(a0)
        proc->need_resched = 0;                              // 不需要重新调度
ffffffffc0203166:	00052c23          	sw	zero,24(a0)
        proc->parent = NULL;                                 // 父进程：空
ffffffffc020316a:	02053023          	sd	zero,32(a0)
        proc->mm = NULL;                                     // 内存管理结构：空
ffffffffc020316e:	02053423          	sd	zero,40(a0)
        memset(&(proc->context), 0, sizeof(struct context)); // 上下文清零
ffffffffc0203172:	03050513          	addi	a0,a0,48
ffffffffc0203176:	437000ef          	jal	ra,ffffffffc0203dac <memset>
        proc->tf = NULL;                                     // 中断帧：空
        proc->pgdir = boot_pgdir_pa;                         // 页目录基址：内核页目录表的基址
ffffffffc020317a:	0000a797          	auipc	a5,0xa
ffffffffc020317e:	3267b783          	ld	a5,806(a5) # ffffffffc020d4a0 <boot_pgdir_pa>
        proc->tf = NULL;                                     // 中断帧：空
ffffffffc0203182:	0a043023          	sd	zero,160(s0)
        proc->pgdir = boot_pgdir_pa;                         // 页目录基址：内核页目录表的基址
ffffffffc0203186:	f45c                	sd	a5,168(s0)
        proc->flags = 0;                                     // 进程标志：0
ffffffffc0203188:	0a042823          	sw	zero,176(s0)
        memset(proc->name, 0, PROC_NAME_LEN + 1);            // 进程名清零
ffffffffc020318c:	4641                	li	a2,16
ffffffffc020318e:	4581                	li	a1,0
ffffffffc0203190:	0b440513          	addi	a0,s0,180
ffffffffc0203194:	419000ef          	jal	ra,ffffffffc0203dac <memset>
    }
    return proc;
}
ffffffffc0203198:	60a2                	ld	ra,8(sp)
ffffffffc020319a:	8522                	mv	a0,s0
ffffffffc020319c:	6402                	ld	s0,0(sp)
ffffffffc020319e:	0141                	addi	sp,sp,16
ffffffffc02031a0:	8082                	ret

ffffffffc02031a2 <forkret>:
// NOTE: the addr of forkret is setted in copy_thread function
//       after switch_to, the current proc will execute here.
static void
forkret(void)
{
    forkrets(current->tf);
ffffffffc02031a2:	0000a797          	auipc	a5,0xa
ffffffffc02031a6:	32e7b783          	ld	a5,814(a5) # ffffffffc020d4d0 <current>
ffffffffc02031aa:	73c8                	ld	a0,160(a5)
ffffffffc02031ac:	c29fd06f          	j	ffffffffc0200dd4 <forkrets>

ffffffffc02031b0 <init_main>:
}

// init_main - the second kernel thread used to create user_main kernel threads
static int
init_main(void *arg)
{
ffffffffc02031b0:	7179                	addi	sp,sp,-48
ffffffffc02031b2:	ec26                	sd	s1,24(sp)
    memset(name, 0, sizeof(name));
ffffffffc02031b4:	0000a497          	auipc	s1,0xa
ffffffffc02031b8:	29448493          	addi	s1,s1,660 # ffffffffc020d448 <name.2>
{
ffffffffc02031bc:	f022                	sd	s0,32(sp)
ffffffffc02031be:	e84a                	sd	s2,16(sp)
ffffffffc02031c0:	842a                	mv	s0,a0
    cprintf("this initproc, pid = %d, name = \"%s\"\n", current->pid, get_proc_name(current));
ffffffffc02031c2:	0000a917          	auipc	s2,0xa
ffffffffc02031c6:	30e93903          	ld	s2,782(s2) # ffffffffc020d4d0 <current>
    memset(name, 0, sizeof(name));
ffffffffc02031ca:	4641                	li	a2,16
ffffffffc02031cc:	4581                	li	a1,0
ffffffffc02031ce:	8526                	mv	a0,s1
{
ffffffffc02031d0:	f406                	sd	ra,40(sp)
ffffffffc02031d2:	e44e                	sd	s3,8(sp)
    cprintf("this initproc, pid = %d, name = \"%s\"\n", current->pid, get_proc_name(current));
ffffffffc02031d4:	00492983          	lw	s3,4(s2)
    memset(name, 0, sizeof(name));
ffffffffc02031d8:	3d5000ef          	jal	ra,ffffffffc0203dac <memset>
    return memcpy(name, proc->name, PROC_NAME_LEN);
ffffffffc02031dc:	0b490593          	addi	a1,s2,180
ffffffffc02031e0:	463d                	li	a2,15
ffffffffc02031e2:	8526                	mv	a0,s1
ffffffffc02031e4:	3db000ef          	jal	ra,ffffffffc0203dbe <memcpy>
ffffffffc02031e8:	862a                	mv	a2,a0
    cprintf("this initproc, pid = %d, name = \"%s\"\n", current->pid, get_proc_name(current));
ffffffffc02031ea:	85ce                	mv	a1,s3
ffffffffc02031ec:	00002517          	auipc	a0,0x2
ffffffffc02031f0:	2ec50513          	addi	a0,a0,748 # ffffffffc02054d8 <best_fit_pmm_manager+0x920>
ffffffffc02031f4:	fa1fc0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("To U: \"%s\".\n", (const char *)arg);
ffffffffc02031f8:	85a2                	mv	a1,s0
ffffffffc02031fa:	00002517          	auipc	a0,0x2
ffffffffc02031fe:	30650513          	addi	a0,a0,774 # ffffffffc0205500 <best_fit_pmm_manager+0x948>
ffffffffc0203202:	f93fc0ef          	jal	ra,ffffffffc0200194 <cprintf>
    cprintf("To U: \"en.., Bye, Bye. :)\"\n");
ffffffffc0203206:	00002517          	auipc	a0,0x2
ffffffffc020320a:	30a50513          	addi	a0,a0,778 # ffffffffc0205510 <best_fit_pmm_manager+0x958>
ffffffffc020320e:	f87fc0ef          	jal	ra,ffffffffc0200194 <cprintf>
    return 0;
}
ffffffffc0203212:	70a2                	ld	ra,40(sp)
ffffffffc0203214:	7402                	ld	s0,32(sp)
ffffffffc0203216:	64e2                	ld	s1,24(sp)
ffffffffc0203218:	6942                	ld	s2,16(sp)
ffffffffc020321a:	69a2                	ld	s3,8(sp)
ffffffffc020321c:	4501                	li	a0,0
ffffffffc020321e:	6145                	addi	sp,sp,48
ffffffffc0203220:	8082                	ret

ffffffffc0203222 <proc_run>:
{
ffffffffc0203222:	7179                	addi	sp,sp,-48
ffffffffc0203224:	ec4a                	sd	s2,24(sp)
    if (proc != current)
ffffffffc0203226:	0000a917          	auipc	s2,0xa
ffffffffc020322a:	2aa90913          	addi	s2,s2,682 # ffffffffc020d4d0 <current>
{
ffffffffc020322e:	f026                	sd	s1,32(sp)
    if (proc != current)
ffffffffc0203230:	00093483          	ld	s1,0(s2)
{
ffffffffc0203234:	f406                	sd	ra,40(sp)
ffffffffc0203236:	e84e                	sd	s3,16(sp)
    if (proc != current)
ffffffffc0203238:	02a48963          	beq	s1,a0,ffffffffc020326a <proc_run+0x48>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc020323c:	100027f3          	csrr	a5,sstatus
ffffffffc0203240:	8b89                	andi	a5,a5,2
    return 0;
ffffffffc0203242:	4981                	li	s3,0
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0203244:	e3a1                	bnez	a5,ffffffffc0203284 <proc_run+0x62>
            lsatp(next->pgdir);
ffffffffc0203246:	755c                	ld	a5,168(a0)
#define barrier() __asm__ __volatile__("fence" ::: "memory")

static inline void
lsatp(unsigned int pgdir)
{
  write_csr(satp, SATP32_MODE | (pgdir >> RISCV_PGSHIFT));
ffffffffc0203248:	80000737          	lui	a4,0x80000
            current = proc;
ffffffffc020324c:	00a93023          	sd	a0,0(s2)
ffffffffc0203250:	00c7d79b          	srliw	a5,a5,0xc
ffffffffc0203254:	8fd9                	or	a5,a5,a4
ffffffffc0203256:	18079073          	csrw	satp,a5
            switch_to(&(prev->context), &(next->context));
ffffffffc020325a:	03050593          	addi	a1,a0,48
ffffffffc020325e:	03048513          	addi	a0,s1,48
ffffffffc0203262:	574000ef          	jal	ra,ffffffffc02037d6 <switch_to>
    if (flag) {
ffffffffc0203266:	00099863          	bnez	s3,ffffffffc0203276 <proc_run+0x54>
}
ffffffffc020326a:	70a2                	ld	ra,40(sp)
ffffffffc020326c:	7482                	ld	s1,32(sp)
ffffffffc020326e:	6962                	ld	s2,24(sp)
ffffffffc0203270:	69c2                	ld	s3,16(sp)
ffffffffc0203272:	6145                	addi	sp,sp,48
ffffffffc0203274:	8082                	ret
ffffffffc0203276:	70a2                	ld	ra,40(sp)
ffffffffc0203278:	7482                	ld	s1,32(sp)
ffffffffc020327a:	6962                	ld	s2,24(sp)
ffffffffc020327c:	69c2                	ld	s3,16(sp)
ffffffffc020327e:	6145                	addi	sp,sp,48
        intr_enable();
ffffffffc0203280:	eaafd06f          	j	ffffffffc020092a <intr_enable>
ffffffffc0203284:	e42a                	sd	a0,8(sp)
        intr_disable();
ffffffffc0203286:	eaafd0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        return 1;
ffffffffc020328a:	6522                	ld	a0,8(sp)
ffffffffc020328c:	4985                	li	s3,1
ffffffffc020328e:	bf65                	j	ffffffffc0203246 <proc_run+0x24>

ffffffffc0203290 <do_fork>:
{
ffffffffc0203290:	7179                	addi	sp,sp,-48
ffffffffc0203292:	ec26                	sd	s1,24(sp)
    if (nr_process >= MAX_PROCESS)
ffffffffc0203294:	0000a497          	auipc	s1,0xa
ffffffffc0203298:	25448493          	addi	s1,s1,596 # ffffffffc020d4e8 <nr_process>
ffffffffc020329c:	4098                	lw	a4,0(s1)
{
ffffffffc020329e:	f406                	sd	ra,40(sp)
ffffffffc02032a0:	f022                	sd	s0,32(sp)
ffffffffc02032a2:	e84a                	sd	s2,16(sp)
ffffffffc02032a4:	e44e                	sd	s3,8(sp)
    if (nr_process >= MAX_PROCESS)
ffffffffc02032a6:	6785                	lui	a5,0x1
ffffffffc02032a8:	20f75963          	bge	a4,a5,ffffffffc02034ba <do_fork+0x22a>
ffffffffc02032ac:	892e                	mv	s2,a1
ffffffffc02032ae:	8432                	mv	s0,a2
    proc = alloc_proc();
ffffffffc02032b0:	e91ff0ef          	jal	ra,ffffffffc0203140 <alloc_proc>
ffffffffc02032b4:	89aa                	mv	s3,a0
    if (proc == NULL)
ffffffffc02032b6:	20050763          	beqz	a0,ffffffffc02034c4 <do_fork+0x234>
    struct Page *page = alloc_pages(KSTACKPAGE);
ffffffffc02032ba:	4509                	li	a0,2
ffffffffc02032bc:	90dfe0ef          	jal	ra,ffffffffc0201bc8 <alloc_pages>
    if (page != NULL)
ffffffffc02032c0:	1e050863          	beqz	a0,ffffffffc02034b0 <do_fork+0x220>
    return page - pages + nbase;
ffffffffc02032c4:	0000a697          	auipc	a3,0xa
ffffffffc02032c8:	1f46b683          	ld	a3,500(a3) # ffffffffc020d4b8 <pages>
ffffffffc02032cc:	40d506b3          	sub	a3,a0,a3
ffffffffc02032d0:	8699                	srai	a3,a3,0x6
ffffffffc02032d2:	00002517          	auipc	a0,0x2
ffffffffc02032d6:	5fe53503          	ld	a0,1534(a0) # ffffffffc02058d0 <nbase>
ffffffffc02032da:	96aa                	add	a3,a3,a0
    return KADDR(page2pa(page));
ffffffffc02032dc:	00c69793          	slli	a5,a3,0xc
ffffffffc02032e0:	83b1                	srli	a5,a5,0xc
ffffffffc02032e2:	0000a717          	auipc	a4,0xa
ffffffffc02032e6:	1ce73703          	ld	a4,462(a4) # ffffffffc020d4b0 <npage>
    return page2ppn(page) << PGSHIFT;
ffffffffc02032ea:	06b2                	slli	a3,a3,0xc
    return KADDR(page2pa(page));
ffffffffc02032ec:	1ee7fe63          	bgeu	a5,a4,ffffffffc02034e8 <do_fork+0x258>
    assert(current->mm == NULL);
ffffffffc02032f0:	0000a797          	auipc	a5,0xa
ffffffffc02032f4:	1e07b783          	ld	a5,480(a5) # ffffffffc020d4d0 <current>
ffffffffc02032f8:	779c                	ld	a5,40(a5)
ffffffffc02032fa:	0000a717          	auipc	a4,0xa
ffffffffc02032fe:	1ce73703          	ld	a4,462(a4) # ffffffffc020d4c8 <va_pa_offset>
ffffffffc0203302:	96ba                	add	a3,a3,a4
        proc->kstack = (uintptr_t)page2kva(page);
ffffffffc0203304:	00d9b823          	sd	a3,16(s3)
    assert(current->mm == NULL);
ffffffffc0203308:	1c079063          	bnez	a5,ffffffffc02034c8 <do_fork+0x238>
    proc->tf = (struct trapframe *)(proc->kstack + KSTACKSIZE - sizeof(struct trapframe));
ffffffffc020330c:	6789                	lui	a5,0x2
ffffffffc020330e:	ee078793          	addi	a5,a5,-288 # 1ee0 <kern_entry-0xffffffffc01fe120>
ffffffffc0203312:	96be                	add	a3,a3,a5
    *(proc->tf) = *tf;
ffffffffc0203314:	8622                	mv	a2,s0
    proc->tf = (struct trapframe *)(proc->kstack + KSTACKSIZE - sizeof(struct trapframe));
ffffffffc0203316:	0ad9b023          	sd	a3,160(s3)
    *(proc->tf) = *tf;
ffffffffc020331a:	87b6                	mv	a5,a3
ffffffffc020331c:	12040893          	addi	a7,s0,288
ffffffffc0203320:	00063803          	ld	a6,0(a2)
ffffffffc0203324:	6608                	ld	a0,8(a2)
ffffffffc0203326:	6a0c                	ld	a1,16(a2)
ffffffffc0203328:	6e18                	ld	a4,24(a2)
ffffffffc020332a:	0107b023          	sd	a6,0(a5)
ffffffffc020332e:	e788                	sd	a0,8(a5)
ffffffffc0203330:	eb8c                	sd	a1,16(a5)
ffffffffc0203332:	ef98                	sd	a4,24(a5)
ffffffffc0203334:	02060613          	addi	a2,a2,32
ffffffffc0203338:	02078793          	addi	a5,a5,32
ffffffffc020333c:	ff1612e3          	bne	a2,a7,ffffffffc0203320 <do_fork+0x90>
    proc->tf->gpr.a0 = 0;
ffffffffc0203340:	0406b823          	sd	zero,80(a3)
    proc->tf->gpr.sp = (esp == 0) ? (uintptr_t)proc->tf : esp;
ffffffffc0203344:	12090463          	beqz	s2,ffffffffc020346c <do_fork+0x1dc>
ffffffffc0203348:	0126b823          	sd	s2,16(a3)
    proc->context.ra = (uintptr_t)forkret;
ffffffffc020334c:	00000797          	auipc	a5,0x0
ffffffffc0203350:	e5678793          	addi	a5,a5,-426 # ffffffffc02031a2 <forkret>
ffffffffc0203354:	02f9b823          	sd	a5,48(s3)
    proc->context.sp = (uintptr_t)(proc->tf);
ffffffffc0203358:	02d9bc23          	sd	a3,56(s3)
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc020335c:	100027f3          	csrr	a5,sstatus
ffffffffc0203360:	8b89                	andi	a5,a5,2
    return 0;
ffffffffc0203362:	4901                	li	s2,0
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0203364:	12079563          	bnez	a5,ffffffffc020348e <do_fork+0x1fe>
    if (++last_pid >= MAX_PID)
ffffffffc0203368:	00006817          	auipc	a6,0x6
ffffffffc020336c:	cc080813          	addi	a6,a6,-832 # ffffffffc0209028 <last_pid.1>
ffffffffc0203370:	00082783          	lw	a5,0(a6)
ffffffffc0203374:	6709                	lui	a4,0x2
ffffffffc0203376:	0017851b          	addiw	a0,a5,1
ffffffffc020337a:	00a82023          	sw	a0,0(a6)
ffffffffc020337e:	08e55063          	bge	a0,a4,ffffffffc02033fe <do_fork+0x16e>
    if (last_pid >= next_safe)
ffffffffc0203382:	00006317          	auipc	t1,0x6
ffffffffc0203386:	caa30313          	addi	t1,t1,-854 # ffffffffc020902c <next_safe.0>
ffffffffc020338a:	00032783          	lw	a5,0(t1)
ffffffffc020338e:	0000a417          	auipc	s0,0xa
ffffffffc0203392:	0ca40413          	addi	s0,s0,202 # ffffffffc020d458 <proc_list>
ffffffffc0203396:	06f55c63          	bge	a0,a5,ffffffffc020340e <do_fork+0x17e>
        proc->pid = get_pid();
ffffffffc020339a:	00a9a223          	sw	a0,4(s3)
    list_add(hash_list + pid_hashfn(proc->pid), &(proc->hash_link));
ffffffffc020339e:	45a9                	li	a1,10
ffffffffc02033a0:	2501                	sext.w	a0,a0
ffffffffc02033a2:	564000ef          	jal	ra,ffffffffc0203906 <hash32>
ffffffffc02033a6:	02051793          	slli	a5,a0,0x20
ffffffffc02033aa:	01c7d513          	srli	a0,a5,0x1c
ffffffffc02033ae:	00006797          	auipc	a5,0x6
ffffffffc02033b2:	09a78793          	addi	a5,a5,154 # ffffffffc0209448 <hash_list>
ffffffffc02033b6:	953e                	add	a0,a0,a5
    __list_add(elm, listelm, listelm->next);
ffffffffc02033b8:	6510                	ld	a2,8(a0)
ffffffffc02033ba:	0d898793          	addi	a5,s3,216
ffffffffc02033be:	6414                	ld	a3,8(s0)
        nr_process++;
ffffffffc02033c0:	4098                	lw	a4,0(s1)
    prev->next = next->prev = elm;
ffffffffc02033c2:	e21c                	sd	a5,0(a2)
ffffffffc02033c4:	e51c                	sd	a5,8(a0)
    elm->next = next;
ffffffffc02033c6:	0ec9b023          	sd	a2,224(s3)
        list_add(&proc_list, &(proc->list_link));
ffffffffc02033ca:	0c898793          	addi	a5,s3,200
    elm->prev = prev;
ffffffffc02033ce:	0ca9bc23          	sd	a0,216(s3)
    prev->next = next->prev = elm;
ffffffffc02033d2:	e29c                	sd	a5,0(a3)
        nr_process++;
ffffffffc02033d4:	2705                	addiw	a4,a4,1
ffffffffc02033d6:	e41c                	sd	a5,8(s0)
    elm->next = next;
ffffffffc02033d8:	0cd9b823          	sd	a3,208(s3)
    elm->prev = prev;
ffffffffc02033dc:	0c89b423          	sd	s0,200(s3)
ffffffffc02033e0:	c098                	sw	a4,0(s1)
    if (flag) {
ffffffffc02033e2:	0a091a63          	bnez	s2,ffffffffc0203496 <do_fork+0x206>
    wakeup_proc(proc);
ffffffffc02033e6:	854e                	mv	a0,s3
ffffffffc02033e8:	458000ef          	jal	ra,ffffffffc0203840 <wakeup_proc>
    ret = proc->pid;
ffffffffc02033ec:	0049a503          	lw	a0,4(s3)
}
ffffffffc02033f0:	70a2                	ld	ra,40(sp)
ffffffffc02033f2:	7402                	ld	s0,32(sp)
ffffffffc02033f4:	64e2                	ld	s1,24(sp)
ffffffffc02033f6:	6942                	ld	s2,16(sp)
ffffffffc02033f8:	69a2                	ld	s3,8(sp)
ffffffffc02033fa:	6145                	addi	sp,sp,48
ffffffffc02033fc:	8082                	ret
        last_pid = 1;
ffffffffc02033fe:	4785                	li	a5,1
ffffffffc0203400:	00f82023          	sw	a5,0(a6)
        goto inside; // 需要重新扫描进程列表
ffffffffc0203404:	4505                	li	a0,1
ffffffffc0203406:	00006317          	auipc	t1,0x6
ffffffffc020340a:	c2630313          	addi	t1,t1,-986 # ffffffffc020902c <next_safe.0>
    return listelm->next;
ffffffffc020340e:	0000a417          	auipc	s0,0xa
ffffffffc0203412:	04a40413          	addi	s0,s0,74 # ffffffffc020d458 <proc_list>
ffffffffc0203416:	00843e03          	ld	t3,8(s0)
        next_safe = MAX_PID;
ffffffffc020341a:	6789                	lui	a5,0x2
ffffffffc020341c:	00f32023          	sw	a5,0(t1)
ffffffffc0203420:	86aa                	mv	a3,a0
ffffffffc0203422:	4581                	li	a1,0
        while ((le = list_next(le)) != list)
ffffffffc0203424:	6e89                	lui	t4,0x2
ffffffffc0203426:	088e0063          	beq	t3,s0,ffffffffc02034a6 <do_fork+0x216>
ffffffffc020342a:	88ae                	mv	a7,a1
ffffffffc020342c:	87f2                	mv	a5,t3
ffffffffc020342e:	6609                	lui	a2,0x2
ffffffffc0203430:	a811                	j	ffffffffc0203444 <do_fork+0x1b4>
            else if (proc->pid > last_pid && next_safe > proc->pid)
ffffffffc0203432:	00e6d663          	bge	a3,a4,ffffffffc020343e <do_fork+0x1ae>
ffffffffc0203436:	00c75463          	bge	a4,a2,ffffffffc020343e <do_fork+0x1ae>
ffffffffc020343a:	863a                	mv	a2,a4
ffffffffc020343c:	4885                	li	a7,1
ffffffffc020343e:	679c                	ld	a5,8(a5)
        while ((le = list_next(le)) != list)
ffffffffc0203440:	00878d63          	beq	a5,s0,ffffffffc020345a <do_fork+0x1ca>
            if (proc->pid == last_pid)
ffffffffc0203444:	f3c7a703          	lw	a4,-196(a5) # 1f3c <kern_entry-0xffffffffc01fe0c4>
ffffffffc0203448:	fed715e3          	bne	a4,a3,ffffffffc0203432 <do_fork+0x1a2>
                if (++last_pid >= next_safe)
ffffffffc020344c:	2685                	addiw	a3,a3,1
ffffffffc020344e:	04c6d763          	bge	a3,a2,ffffffffc020349c <do_fork+0x20c>
ffffffffc0203452:	679c                	ld	a5,8(a5)
ffffffffc0203454:	4585                	li	a1,1
        while ((le = list_next(le)) != list)
ffffffffc0203456:	fe8797e3          	bne	a5,s0,ffffffffc0203444 <do_fork+0x1b4>
ffffffffc020345a:	c581                	beqz	a1,ffffffffc0203462 <do_fork+0x1d2>
ffffffffc020345c:	00d82023          	sw	a3,0(a6)
ffffffffc0203460:	8536                	mv	a0,a3
ffffffffc0203462:	f2088ce3          	beqz	a7,ffffffffc020339a <do_fork+0x10a>
ffffffffc0203466:	00c32023          	sw	a2,0(t1)
ffffffffc020346a:	bf05                	j	ffffffffc020339a <do_fork+0x10a>
    proc->tf->gpr.sp = (esp == 0) ? (uintptr_t)proc->tf : esp;
ffffffffc020346c:	8936                	mv	s2,a3
ffffffffc020346e:	0126b823          	sd	s2,16(a3)
    proc->context.ra = (uintptr_t)forkret;
ffffffffc0203472:	00000797          	auipc	a5,0x0
ffffffffc0203476:	d3078793          	addi	a5,a5,-720 # ffffffffc02031a2 <forkret>
ffffffffc020347a:	02f9b823          	sd	a5,48(s3)
    proc->context.sp = (uintptr_t)(proc->tf);
ffffffffc020347e:	02d9bc23          	sd	a3,56(s3)
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0203482:	100027f3          	csrr	a5,sstatus
ffffffffc0203486:	8b89                	andi	a5,a5,2
    return 0;
ffffffffc0203488:	4901                	li	s2,0
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc020348a:	ec078fe3          	beqz	a5,ffffffffc0203368 <do_fork+0xd8>
        intr_disable();
ffffffffc020348e:	ca2fd0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        return 1;
ffffffffc0203492:	4905                	li	s2,1
ffffffffc0203494:	bdd1                	j	ffffffffc0203368 <do_fork+0xd8>
        intr_enable();
ffffffffc0203496:	c94fd0ef          	jal	ra,ffffffffc020092a <intr_enable>
ffffffffc020349a:	b7b1                	j	ffffffffc02033e6 <do_fork+0x156>
                    if (last_pid >= MAX_PID)
ffffffffc020349c:	01d6c363          	blt	a3,t4,ffffffffc02034a2 <do_fork+0x212>
                        last_pid = 1;
ffffffffc02034a0:	4685                	li	a3,1
                    goto repeat; // 重新开始扫描
ffffffffc02034a2:	4585                	li	a1,1
ffffffffc02034a4:	b749                	j	ffffffffc0203426 <do_fork+0x196>
ffffffffc02034a6:	cd81                	beqz	a1,ffffffffc02034be <do_fork+0x22e>
ffffffffc02034a8:	00d82023          	sw	a3,0(a6)
    return last_pid;
ffffffffc02034ac:	8536                	mv	a0,a3
ffffffffc02034ae:	b5f5                	j	ffffffffc020339a <do_fork+0x10a>
    kfree(proc);
ffffffffc02034b0:	854e                	mv	a0,s3
ffffffffc02034b2:	de8fe0ef          	jal	ra,ffffffffc0201a9a <kfree>
    ret = -E_NO_MEM;
ffffffffc02034b6:	5571                	li	a0,-4
    goto fork_out;
ffffffffc02034b8:	bf25                	j	ffffffffc02033f0 <do_fork+0x160>
    int ret = -E_NO_FREE_PROC;
ffffffffc02034ba:	556d                	li	a0,-5
ffffffffc02034bc:	bf15                	j	ffffffffc02033f0 <do_fork+0x160>
    return last_pid;
ffffffffc02034be:	00082503          	lw	a0,0(a6)
ffffffffc02034c2:	bde1                	j	ffffffffc020339a <do_fork+0x10a>
    ret = -E_NO_MEM;
ffffffffc02034c4:	5571                	li	a0,-4
    return ret;
ffffffffc02034c6:	b72d                	j	ffffffffc02033f0 <do_fork+0x160>
    assert(current->mm == NULL);
ffffffffc02034c8:	00002697          	auipc	a3,0x2
ffffffffc02034cc:	06868693          	addi	a3,a3,104 # ffffffffc0205530 <best_fit_pmm_manager+0x978>
ffffffffc02034d0:	00001617          	auipc	a2,0x1
ffffffffc02034d4:	3a860613          	addi	a2,a2,936 # ffffffffc0204878 <commands+0x810>
ffffffffc02034d8:	13e00593          	li	a1,318
ffffffffc02034dc:	00002517          	auipc	a0,0x2
ffffffffc02034e0:	06c50513          	addi	a0,a0,108 # ffffffffc0205548 <best_fit_pmm_manager+0x990>
ffffffffc02034e4:	f77fc0ef          	jal	ra,ffffffffc020045a <__panic>
ffffffffc02034e8:	00001617          	auipc	a2,0x1
ffffffffc02034ec:	70860613          	addi	a2,a2,1800 # ffffffffc0204bf0 <best_fit_pmm_manager+0x38>
ffffffffc02034f0:	07100593          	li	a1,113
ffffffffc02034f4:	00001517          	auipc	a0,0x1
ffffffffc02034f8:	72450513          	addi	a0,a0,1828 # ffffffffc0204c18 <best_fit_pmm_manager+0x60>
ffffffffc02034fc:	f5ffc0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0203500 <kernel_thread>:
{
ffffffffc0203500:	7129                	addi	sp,sp,-320
ffffffffc0203502:	fa22                	sd	s0,304(sp)
ffffffffc0203504:	f626                	sd	s1,296(sp)
ffffffffc0203506:	f24a                	sd	s2,288(sp)
ffffffffc0203508:	84ae                	mv	s1,a1
ffffffffc020350a:	892a                	mv	s2,a0
ffffffffc020350c:	8432                	mv	s0,a2
    memset(&tf, 0, sizeof(struct trapframe));
ffffffffc020350e:	4581                	li	a1,0
ffffffffc0203510:	12000613          	li	a2,288
ffffffffc0203514:	850a                	mv	a0,sp
{
ffffffffc0203516:	fe06                	sd	ra,312(sp)
    memset(&tf, 0, sizeof(struct trapframe));
ffffffffc0203518:	095000ef          	jal	ra,ffffffffc0203dac <memset>
    tf.gpr.s0 = (uintptr_t)fn;
ffffffffc020351c:	e0ca                	sd	s2,64(sp)
    tf.gpr.s1 = (uintptr_t)arg;
ffffffffc020351e:	e4a6                	sd	s1,72(sp)
    tf.status = (read_csr(sstatus) | SSTATUS_SPP | SSTATUS_SPIE) & ~SSTATUS_SIE;
ffffffffc0203520:	100027f3          	csrr	a5,sstatus
ffffffffc0203524:	edd7f793          	andi	a5,a5,-291
ffffffffc0203528:	1207e793          	ori	a5,a5,288
ffffffffc020352c:	e23e                	sd	a5,256(sp)
    return do_fork(clone_flags | CLONE_VM, 0, &tf);
ffffffffc020352e:	860a                	mv	a2,sp
ffffffffc0203530:	10046513          	ori	a0,s0,256
    tf.epc = (uintptr_t)kernel_thread_entry;
ffffffffc0203534:	00000797          	auipc	a5,0x0
ffffffffc0203538:	c0478793          	addi	a5,a5,-1020 # ffffffffc0203138 <kernel_thread_entry>
    return do_fork(clone_flags | CLONE_VM, 0, &tf);
ffffffffc020353c:	4581                	li	a1,0
    tf.epc = (uintptr_t)kernel_thread_entry;
ffffffffc020353e:	e63e                	sd	a5,264(sp)
    return do_fork(clone_flags | CLONE_VM, 0, &tf);
ffffffffc0203540:	d51ff0ef          	jal	ra,ffffffffc0203290 <do_fork>
}
ffffffffc0203544:	70f2                	ld	ra,312(sp)
ffffffffc0203546:	7452                	ld	s0,304(sp)
ffffffffc0203548:	74b2                	ld	s1,296(sp)
ffffffffc020354a:	7912                	ld	s2,288(sp)
ffffffffc020354c:	6131                	addi	sp,sp,320
ffffffffc020354e:	8082                	ret

ffffffffc0203550 <do_exit>:
{
ffffffffc0203550:	1141                	addi	sp,sp,-16
    panic("process exit!!.\n");
ffffffffc0203552:	00002617          	auipc	a2,0x2
ffffffffc0203556:	00e60613          	addi	a2,a2,14 # ffffffffc0205560 <best_fit_pmm_manager+0x9a8>
ffffffffc020355a:	1ab00593          	li	a1,427
ffffffffc020355e:	00002517          	auipc	a0,0x2
ffffffffc0203562:	fea50513          	addi	a0,a0,-22 # ffffffffc0205548 <best_fit_pmm_manager+0x990>
{
ffffffffc0203566:	e406                	sd	ra,8(sp)
    panic("process exit!!.\n");
ffffffffc0203568:	ef3fc0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc020356c <proc_init>:

// proc_init - set up the first kernel thread idleproc "idle" by itself and
//           - create the second kernel thread init_main
void proc_init(void)
{
ffffffffc020356c:	7179                	addi	sp,sp,-48
ffffffffc020356e:	ec26                	sd	s1,24(sp)
    elm->prev = elm->next = elm;
ffffffffc0203570:	0000a797          	auipc	a5,0xa
ffffffffc0203574:	ee878793          	addi	a5,a5,-280 # ffffffffc020d458 <proc_list>
ffffffffc0203578:	f406                	sd	ra,40(sp)
ffffffffc020357a:	f022                	sd	s0,32(sp)
ffffffffc020357c:	e84a                	sd	s2,16(sp)
ffffffffc020357e:	e44e                	sd	s3,8(sp)
ffffffffc0203580:	00006497          	auipc	s1,0x6
ffffffffc0203584:	ec848493          	addi	s1,s1,-312 # ffffffffc0209448 <hash_list>
ffffffffc0203588:	e79c                	sd	a5,8(a5)
ffffffffc020358a:	e39c                	sd	a5,0(a5)
    int i;

    list_init(&proc_list);
    for (i = 0; i < HASH_LIST_SIZE; i++)
ffffffffc020358c:	0000a717          	auipc	a4,0xa
ffffffffc0203590:	ebc70713          	addi	a4,a4,-324 # ffffffffc020d448 <name.2>
ffffffffc0203594:	87a6                	mv	a5,s1
ffffffffc0203596:	e79c                	sd	a5,8(a5)
ffffffffc0203598:	e39c                	sd	a5,0(a5)
ffffffffc020359a:	07c1                	addi	a5,a5,16
ffffffffc020359c:	fef71de3          	bne	a4,a5,ffffffffc0203596 <proc_init+0x2a>
    {
        list_init(hash_list + i);
    }

    if ((idleproc = alloc_proc()) == NULL)
ffffffffc02035a0:	ba1ff0ef          	jal	ra,ffffffffc0203140 <alloc_proc>
ffffffffc02035a4:	0000a917          	auipc	s2,0xa
ffffffffc02035a8:	f3490913          	addi	s2,s2,-204 # ffffffffc020d4d8 <idleproc>
ffffffffc02035ac:	00a93023          	sd	a0,0(s2)
ffffffffc02035b0:	18050d63          	beqz	a0,ffffffffc020374a <proc_init+0x1de>
    {
        panic("cannot alloc idleproc.\n");
    }

    // check the proc structure
    int *context_mem = (int *)kmalloc(sizeof(struct context));
ffffffffc02035b4:	07000513          	li	a0,112
ffffffffc02035b8:	c32fe0ef          	jal	ra,ffffffffc02019ea <kmalloc>
    memset(context_mem, 0, sizeof(struct context));
ffffffffc02035bc:	07000613          	li	a2,112
ffffffffc02035c0:	4581                	li	a1,0
    int *context_mem = (int *)kmalloc(sizeof(struct context));
ffffffffc02035c2:	842a                	mv	s0,a0
    memset(context_mem, 0, sizeof(struct context));
ffffffffc02035c4:	7e8000ef          	jal	ra,ffffffffc0203dac <memset>
    int context_init_flag = memcmp(&(idleproc->context), context_mem, sizeof(struct context));
ffffffffc02035c8:	00093503          	ld	a0,0(s2)
ffffffffc02035cc:	85a2                	mv	a1,s0
ffffffffc02035ce:	07000613          	li	a2,112
ffffffffc02035d2:	03050513          	addi	a0,a0,48
ffffffffc02035d6:	001000ef          	jal	ra,ffffffffc0203dd6 <memcmp>
ffffffffc02035da:	89aa                	mv	s3,a0

    int *proc_name_mem = (int *)kmalloc(PROC_NAME_LEN);
ffffffffc02035dc:	453d                	li	a0,15
ffffffffc02035de:	c0cfe0ef          	jal	ra,ffffffffc02019ea <kmalloc>
    memset(proc_name_mem, 0, PROC_NAME_LEN);
ffffffffc02035e2:	463d                	li	a2,15
ffffffffc02035e4:	4581                	li	a1,0
    int *proc_name_mem = (int *)kmalloc(PROC_NAME_LEN);
ffffffffc02035e6:	842a                	mv	s0,a0
    memset(proc_name_mem, 0, PROC_NAME_LEN);
ffffffffc02035e8:	7c4000ef          	jal	ra,ffffffffc0203dac <memset>
    int proc_name_flag = memcmp(&(idleproc->name), proc_name_mem, PROC_NAME_LEN);
ffffffffc02035ec:	00093503          	ld	a0,0(s2)
ffffffffc02035f0:	463d                	li	a2,15
ffffffffc02035f2:	85a2                	mv	a1,s0
ffffffffc02035f4:	0b450513          	addi	a0,a0,180
ffffffffc02035f8:	7de000ef          	jal	ra,ffffffffc0203dd6 <memcmp>

    if (idleproc->pgdir == boot_pgdir_pa && idleproc->tf == NULL && !context_init_flag && idleproc->state == PROC_UNINIT && idleproc->pid == -1 && idleproc->runs == 0 && idleproc->kstack == 0 && idleproc->need_resched == 0 && idleproc->parent == NULL && idleproc->mm == NULL && idleproc->flags == 0 && !proc_name_flag)
ffffffffc02035fc:	00093783          	ld	a5,0(s2)
ffffffffc0203600:	0000a717          	auipc	a4,0xa
ffffffffc0203604:	ea073703          	ld	a4,-352(a4) # ffffffffc020d4a0 <boot_pgdir_pa>
ffffffffc0203608:	77d4                	ld	a3,168(a5)
ffffffffc020360a:	0ee68463          	beq	a3,a4,ffffffffc02036f2 <proc_init+0x186>
    {
        cprintf("alloc_proc() correct!\n");
    }

    idleproc->pid = 0;
    idleproc->state = PROC_RUNNABLE;
ffffffffc020360e:	4709                	li	a4,2
ffffffffc0203610:	e398                	sd	a4,0(a5)
    idleproc->kstack = (uintptr_t)bootstack;
ffffffffc0203612:	00003717          	auipc	a4,0x3
ffffffffc0203616:	9ee70713          	addi	a4,a4,-1554 # ffffffffc0206000 <bootstack>
    memset(proc->name, 0, sizeof(proc->name));
ffffffffc020361a:	0b478413          	addi	s0,a5,180
    idleproc->kstack = (uintptr_t)bootstack;
ffffffffc020361e:	eb98                	sd	a4,16(a5)
    idleproc->need_resched = 1;
ffffffffc0203620:	4705                	li	a4,1
ffffffffc0203622:	cf98                	sw	a4,24(a5)
    memset(proc->name, 0, sizeof(proc->name));
ffffffffc0203624:	4641                	li	a2,16
ffffffffc0203626:	4581                	li	a1,0
ffffffffc0203628:	8522                	mv	a0,s0
ffffffffc020362a:	782000ef          	jal	ra,ffffffffc0203dac <memset>
    return memcpy(proc->name, name, PROC_NAME_LEN);
ffffffffc020362e:	463d                	li	a2,15
ffffffffc0203630:	00002597          	auipc	a1,0x2
ffffffffc0203634:	f7858593          	addi	a1,a1,-136 # ffffffffc02055a8 <best_fit_pmm_manager+0x9f0>
ffffffffc0203638:	8522                	mv	a0,s0
ffffffffc020363a:	784000ef          	jal	ra,ffffffffc0203dbe <memcpy>
    set_proc_name(idleproc, "idle");
    nr_process++;
ffffffffc020363e:	0000a717          	auipc	a4,0xa
ffffffffc0203642:	eaa70713          	addi	a4,a4,-342 # ffffffffc020d4e8 <nr_process>
ffffffffc0203646:	431c                	lw	a5,0(a4)

    current = idleproc;
ffffffffc0203648:	00093683          	ld	a3,0(s2)

    int pid = kernel_thread(init_main, "Hello world!!", 0);
ffffffffc020364c:	4601                	li	a2,0
    nr_process++;
ffffffffc020364e:	2785                	addiw	a5,a5,1
    int pid = kernel_thread(init_main, "Hello world!!", 0);
ffffffffc0203650:	00002597          	auipc	a1,0x2
ffffffffc0203654:	f6058593          	addi	a1,a1,-160 # ffffffffc02055b0 <best_fit_pmm_manager+0x9f8>
ffffffffc0203658:	00000517          	auipc	a0,0x0
ffffffffc020365c:	b5850513          	addi	a0,a0,-1192 # ffffffffc02031b0 <init_main>
    nr_process++;
ffffffffc0203660:	c31c                	sw	a5,0(a4)
    current = idleproc;
ffffffffc0203662:	0000a797          	auipc	a5,0xa
ffffffffc0203666:	e6d7b723          	sd	a3,-402(a5) # ffffffffc020d4d0 <current>
    int pid = kernel_thread(init_main, "Hello world!!", 0);
ffffffffc020366a:	e97ff0ef          	jal	ra,ffffffffc0203500 <kernel_thread>
ffffffffc020366e:	842a                	mv	s0,a0
    if (pid <= 0)
ffffffffc0203670:	0ea05963          	blez	a0,ffffffffc0203762 <proc_init+0x1f6>
    if (0 < pid && pid < MAX_PID)
ffffffffc0203674:	6789                	lui	a5,0x2
ffffffffc0203676:	fff5071b          	addiw	a4,a0,-1
ffffffffc020367a:	17f9                	addi	a5,a5,-2
ffffffffc020367c:	2501                	sext.w	a0,a0
ffffffffc020367e:	02e7e363          	bltu	a5,a4,ffffffffc02036a4 <proc_init+0x138>
        list_entry_t *list = hash_list + pid_hashfn(pid), *le = list;
ffffffffc0203682:	45a9                	li	a1,10
ffffffffc0203684:	282000ef          	jal	ra,ffffffffc0203906 <hash32>
ffffffffc0203688:	02051793          	slli	a5,a0,0x20
ffffffffc020368c:	01c7d693          	srli	a3,a5,0x1c
ffffffffc0203690:	96a6                	add	a3,a3,s1
ffffffffc0203692:	87b6                	mv	a5,a3
        while ((le = list_next(le)) != list)
ffffffffc0203694:	a029                	j	ffffffffc020369e <proc_init+0x132>
            if (proc->pid == pid)
ffffffffc0203696:	f2c7a703          	lw	a4,-212(a5) # 1f2c <kern_entry-0xffffffffc01fe0d4>
ffffffffc020369a:	0a870563          	beq	a4,s0,ffffffffc0203744 <proc_init+0x1d8>
    return listelm->next;
ffffffffc020369e:	679c                	ld	a5,8(a5)
        while ((le = list_next(le)) != list)
ffffffffc02036a0:	fef69be3          	bne	a3,a5,ffffffffc0203696 <proc_init+0x12a>
    return NULL;
ffffffffc02036a4:	4781                	li	a5,0
    memset(proc->name, 0, sizeof(proc->name));
ffffffffc02036a6:	0b478493          	addi	s1,a5,180
ffffffffc02036aa:	4641                	li	a2,16
ffffffffc02036ac:	4581                	li	a1,0
    {
        panic("create init_main failed.\n");
    }

    initproc = find_proc(pid);
ffffffffc02036ae:	0000a417          	auipc	s0,0xa
ffffffffc02036b2:	e3240413          	addi	s0,s0,-462 # ffffffffc020d4e0 <initproc>
    memset(proc->name, 0, sizeof(proc->name));
ffffffffc02036b6:	8526                	mv	a0,s1
    initproc = find_proc(pid);
ffffffffc02036b8:	e01c                	sd	a5,0(s0)
    memset(proc->name, 0, sizeof(proc->name));
ffffffffc02036ba:	6f2000ef          	jal	ra,ffffffffc0203dac <memset>
    return memcpy(proc->name, name, PROC_NAME_LEN);
ffffffffc02036be:	463d                	li	a2,15
ffffffffc02036c0:	00002597          	auipc	a1,0x2
ffffffffc02036c4:	f2058593          	addi	a1,a1,-224 # ffffffffc02055e0 <best_fit_pmm_manager+0xa28>
ffffffffc02036c8:	8526                	mv	a0,s1
ffffffffc02036ca:	6f4000ef          	jal	ra,ffffffffc0203dbe <memcpy>
    set_proc_name(initproc, "init");

    assert(idleproc != NULL && idleproc->pid == 0);
ffffffffc02036ce:	00093783          	ld	a5,0(s2)
ffffffffc02036d2:	c7e1                	beqz	a5,ffffffffc020379a <proc_init+0x22e>
ffffffffc02036d4:	43dc                	lw	a5,4(a5)
ffffffffc02036d6:	e3f1                	bnez	a5,ffffffffc020379a <proc_init+0x22e>
    assert(initproc != NULL && initproc->pid == 1);
ffffffffc02036d8:	601c                	ld	a5,0(s0)
ffffffffc02036da:	c3c5                	beqz	a5,ffffffffc020377a <proc_init+0x20e>
ffffffffc02036dc:	43d8                	lw	a4,4(a5)
ffffffffc02036de:	4785                	li	a5,1
ffffffffc02036e0:	08f71d63          	bne	a4,a5,ffffffffc020377a <proc_init+0x20e>
}
ffffffffc02036e4:	70a2                	ld	ra,40(sp)
ffffffffc02036e6:	7402                	ld	s0,32(sp)
ffffffffc02036e8:	64e2                	ld	s1,24(sp)
ffffffffc02036ea:	6942                	ld	s2,16(sp)
ffffffffc02036ec:	69a2                	ld	s3,8(sp)
ffffffffc02036ee:	6145                	addi	sp,sp,48
ffffffffc02036f0:	8082                	ret
    if (idleproc->pgdir == boot_pgdir_pa && idleproc->tf == NULL && !context_init_flag && idleproc->state == PROC_UNINIT && idleproc->pid == -1 && idleproc->runs == 0 && idleproc->kstack == 0 && idleproc->need_resched == 0 && idleproc->parent == NULL && idleproc->mm == NULL && idleproc->flags == 0 && !proc_name_flag)
ffffffffc02036f2:	73d8                	ld	a4,160(a5)
ffffffffc02036f4:	ff09                	bnez	a4,ffffffffc020360e <proc_init+0xa2>
ffffffffc02036f6:	f0099ce3          	bnez	s3,ffffffffc020360e <proc_init+0xa2>
ffffffffc02036fa:	6394                	ld	a3,0(a5)
ffffffffc02036fc:	577d                	li	a4,-1
ffffffffc02036fe:	1702                	slli	a4,a4,0x20
ffffffffc0203700:	f0e697e3          	bne	a3,a4,ffffffffc020360e <proc_init+0xa2>
ffffffffc0203704:	4798                	lw	a4,8(a5)
ffffffffc0203706:	f00714e3          	bnez	a4,ffffffffc020360e <proc_init+0xa2>
ffffffffc020370a:	6b98                	ld	a4,16(a5)
ffffffffc020370c:	f00711e3          	bnez	a4,ffffffffc020360e <proc_init+0xa2>
ffffffffc0203710:	4f98                	lw	a4,24(a5)
ffffffffc0203712:	2701                	sext.w	a4,a4
ffffffffc0203714:	ee071de3          	bnez	a4,ffffffffc020360e <proc_init+0xa2>
ffffffffc0203718:	7398                	ld	a4,32(a5)
ffffffffc020371a:	ee071ae3          	bnez	a4,ffffffffc020360e <proc_init+0xa2>
ffffffffc020371e:	7798                	ld	a4,40(a5)
ffffffffc0203720:	ee0717e3          	bnez	a4,ffffffffc020360e <proc_init+0xa2>
ffffffffc0203724:	0b07a703          	lw	a4,176(a5)
ffffffffc0203728:	8d59                	or	a0,a0,a4
ffffffffc020372a:	0005071b          	sext.w	a4,a0
ffffffffc020372e:	ee0710e3          	bnez	a4,ffffffffc020360e <proc_init+0xa2>
        cprintf("alloc_proc() correct!\n");
ffffffffc0203732:	00002517          	auipc	a0,0x2
ffffffffc0203736:	e5e50513          	addi	a0,a0,-418 # ffffffffc0205590 <best_fit_pmm_manager+0x9d8>
ffffffffc020373a:	a5bfc0ef          	jal	ra,ffffffffc0200194 <cprintf>
    idleproc->pid = 0;
ffffffffc020373e:	00093783          	ld	a5,0(s2)
ffffffffc0203742:	b5f1                	j	ffffffffc020360e <proc_init+0xa2>
            struct proc_struct *proc = le2proc(le, hash_link);
ffffffffc0203744:	f2878793          	addi	a5,a5,-216
ffffffffc0203748:	bfb9                	j	ffffffffc02036a6 <proc_init+0x13a>
        panic("cannot alloc idleproc.\n");
ffffffffc020374a:	00002617          	auipc	a2,0x2
ffffffffc020374e:	e2e60613          	addi	a2,a2,-466 # ffffffffc0205578 <best_fit_pmm_manager+0x9c0>
ffffffffc0203752:	1c600593          	li	a1,454
ffffffffc0203756:	00002517          	auipc	a0,0x2
ffffffffc020375a:	df250513          	addi	a0,a0,-526 # ffffffffc0205548 <best_fit_pmm_manager+0x990>
ffffffffc020375e:	cfdfc0ef          	jal	ra,ffffffffc020045a <__panic>
        panic("create init_main failed.\n");
ffffffffc0203762:	00002617          	auipc	a2,0x2
ffffffffc0203766:	e5e60613          	addi	a2,a2,-418 # ffffffffc02055c0 <best_fit_pmm_manager+0xa08>
ffffffffc020376a:	1e300593          	li	a1,483
ffffffffc020376e:	00002517          	auipc	a0,0x2
ffffffffc0203772:	dda50513          	addi	a0,a0,-550 # ffffffffc0205548 <best_fit_pmm_manager+0x990>
ffffffffc0203776:	ce5fc0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(initproc != NULL && initproc->pid == 1);
ffffffffc020377a:	00002697          	auipc	a3,0x2
ffffffffc020377e:	e9668693          	addi	a3,a3,-362 # ffffffffc0205610 <best_fit_pmm_manager+0xa58>
ffffffffc0203782:	00001617          	auipc	a2,0x1
ffffffffc0203786:	0f660613          	addi	a2,a2,246 # ffffffffc0204878 <commands+0x810>
ffffffffc020378a:	1ea00593          	li	a1,490
ffffffffc020378e:	00002517          	auipc	a0,0x2
ffffffffc0203792:	dba50513          	addi	a0,a0,-582 # ffffffffc0205548 <best_fit_pmm_manager+0x990>
ffffffffc0203796:	cc5fc0ef          	jal	ra,ffffffffc020045a <__panic>
    assert(idleproc != NULL && idleproc->pid == 0);
ffffffffc020379a:	00002697          	auipc	a3,0x2
ffffffffc020379e:	e4e68693          	addi	a3,a3,-434 # ffffffffc02055e8 <best_fit_pmm_manager+0xa30>
ffffffffc02037a2:	00001617          	auipc	a2,0x1
ffffffffc02037a6:	0d660613          	addi	a2,a2,214 # ffffffffc0204878 <commands+0x810>
ffffffffc02037aa:	1e900593          	li	a1,489
ffffffffc02037ae:	00002517          	auipc	a0,0x2
ffffffffc02037b2:	d9a50513          	addi	a0,a0,-614 # ffffffffc0205548 <best_fit_pmm_manager+0x990>
ffffffffc02037b6:	ca5fc0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc02037ba <cpu_idle>:

// cpu_idle - at the end of kern_init, the first kernel thread idleproc will do below works
void cpu_idle(void)
{
ffffffffc02037ba:	1141                	addi	sp,sp,-16
ffffffffc02037bc:	e022                	sd	s0,0(sp)
ffffffffc02037be:	e406                	sd	ra,8(sp)
ffffffffc02037c0:	0000a417          	auipc	s0,0xa
ffffffffc02037c4:	d1040413          	addi	s0,s0,-752 # ffffffffc020d4d0 <current>
    while (1)
    {
        if (current->need_resched)
ffffffffc02037c8:	6018                	ld	a4,0(s0)
ffffffffc02037ca:	4f1c                	lw	a5,24(a4)
ffffffffc02037cc:	2781                	sext.w	a5,a5
ffffffffc02037ce:	dff5                	beqz	a5,ffffffffc02037ca <cpu_idle+0x10>
        {
            schedule();
ffffffffc02037d0:	0a2000ef          	jal	ra,ffffffffc0203872 <schedule>
ffffffffc02037d4:	bfd5                	j	ffffffffc02037c8 <cpu_idle+0xe>

ffffffffc02037d6 <switch_to>:
.text
# void switch_to(struct proc_struct* from, struct proc_struct* to)
.globl switch_to
switch_to:
    # save from's registers
    STORE ra, 0*REGBYTES(a0)
ffffffffc02037d6:	00153023          	sd	ra,0(a0)
    STORE sp, 1*REGBYTES(a0)
ffffffffc02037da:	00253423          	sd	sp,8(a0)
    STORE s0, 2*REGBYTES(a0)
ffffffffc02037de:	e900                	sd	s0,16(a0)
    STORE s1, 3*REGBYTES(a0)
ffffffffc02037e0:	ed04                	sd	s1,24(a0)
    STORE s2, 4*REGBYTES(a0)
ffffffffc02037e2:	03253023          	sd	s2,32(a0)
    STORE s3, 5*REGBYTES(a0)
ffffffffc02037e6:	03353423          	sd	s3,40(a0)
    STORE s4, 6*REGBYTES(a0)
ffffffffc02037ea:	03453823          	sd	s4,48(a0)
    STORE s5, 7*REGBYTES(a0)
ffffffffc02037ee:	03553c23          	sd	s5,56(a0)
    STORE s6, 8*REGBYTES(a0)
ffffffffc02037f2:	05653023          	sd	s6,64(a0)
    STORE s7, 9*REGBYTES(a0)
ffffffffc02037f6:	05753423          	sd	s7,72(a0)
    STORE s8, 10*REGBYTES(a0)
ffffffffc02037fa:	05853823          	sd	s8,80(a0)
    STORE s9, 11*REGBYTES(a0)
ffffffffc02037fe:	05953c23          	sd	s9,88(a0)
    STORE s10, 12*REGBYTES(a0)
ffffffffc0203802:	07a53023          	sd	s10,96(a0)
    STORE s11, 13*REGBYTES(a0)
ffffffffc0203806:	07b53423          	sd	s11,104(a0)

    # restore to's registers
    LOAD ra, 0*REGBYTES(a1)
ffffffffc020380a:	0005b083          	ld	ra,0(a1)
    LOAD sp, 1*REGBYTES(a1)
ffffffffc020380e:	0085b103          	ld	sp,8(a1)
    LOAD s0, 2*REGBYTES(a1)
ffffffffc0203812:	6980                	ld	s0,16(a1)
    LOAD s1, 3*REGBYTES(a1)
ffffffffc0203814:	6d84                	ld	s1,24(a1)
    LOAD s2, 4*REGBYTES(a1)
ffffffffc0203816:	0205b903          	ld	s2,32(a1)
    LOAD s3, 5*REGBYTES(a1)
ffffffffc020381a:	0285b983          	ld	s3,40(a1)
    LOAD s4, 6*REGBYTES(a1)
ffffffffc020381e:	0305ba03          	ld	s4,48(a1)
    LOAD s5, 7*REGBYTES(a1)
ffffffffc0203822:	0385ba83          	ld	s5,56(a1)
    LOAD s6, 8*REGBYTES(a1)
ffffffffc0203826:	0405bb03          	ld	s6,64(a1)
    LOAD s7, 9*REGBYTES(a1)
ffffffffc020382a:	0485bb83          	ld	s7,72(a1)
    LOAD s8, 10*REGBYTES(a1)
ffffffffc020382e:	0505bc03          	ld	s8,80(a1)
    LOAD s9, 11*REGBYTES(a1)
ffffffffc0203832:	0585bc83          	ld	s9,88(a1)
    LOAD s10, 12*REGBYTES(a1)
ffffffffc0203836:	0605bd03          	ld	s10,96(a1)
    LOAD s11, 13*REGBYTES(a1)
ffffffffc020383a:	0685bd83          	ld	s11,104(a1)

    ret
ffffffffc020383e:	8082                	ret

ffffffffc0203840 <wakeup_proc>:
#include <sched.h>
#include <assert.h>

void
wakeup_proc(struct proc_struct *proc) {
    assert(proc->state != PROC_ZOMBIE && proc->state != PROC_RUNNABLE);
ffffffffc0203840:	411c                	lw	a5,0(a0)
ffffffffc0203842:	4705                	li	a4,1
ffffffffc0203844:	37f9                	addiw	a5,a5,-2
ffffffffc0203846:	00f77563          	bgeu	a4,a5,ffffffffc0203850 <wakeup_proc+0x10>
    proc->state = PROC_RUNNABLE;
ffffffffc020384a:	4789                	li	a5,2
ffffffffc020384c:	c11c                	sw	a5,0(a0)
ffffffffc020384e:	8082                	ret
wakeup_proc(struct proc_struct *proc) {
ffffffffc0203850:	1141                	addi	sp,sp,-16
    assert(proc->state != PROC_ZOMBIE && proc->state != PROC_RUNNABLE);
ffffffffc0203852:	00002697          	auipc	a3,0x2
ffffffffc0203856:	de668693          	addi	a3,a3,-538 # ffffffffc0205638 <best_fit_pmm_manager+0xa80>
ffffffffc020385a:	00001617          	auipc	a2,0x1
ffffffffc020385e:	01e60613          	addi	a2,a2,30 # ffffffffc0204878 <commands+0x810>
ffffffffc0203862:	45a5                	li	a1,9
ffffffffc0203864:	00002517          	auipc	a0,0x2
ffffffffc0203868:	e1450513          	addi	a0,a0,-492 # ffffffffc0205678 <best_fit_pmm_manager+0xac0>
wakeup_proc(struct proc_struct *proc) {
ffffffffc020386c:	e406                	sd	ra,8(sp)
    assert(proc->state != PROC_ZOMBIE && proc->state != PROC_RUNNABLE);
ffffffffc020386e:	bedfc0ef          	jal	ra,ffffffffc020045a <__panic>

ffffffffc0203872 <schedule>:
}

void
schedule(void) {
ffffffffc0203872:	1141                	addi	sp,sp,-16
ffffffffc0203874:	e406                	sd	ra,8(sp)
ffffffffc0203876:	e022                	sd	s0,0(sp)
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0203878:	100027f3          	csrr	a5,sstatus
ffffffffc020387c:	8b89                	andi	a5,a5,2
ffffffffc020387e:	4401                	li	s0,0
ffffffffc0203880:	efbd                	bnez	a5,ffffffffc02038fe <schedule+0x8c>
    bool intr_flag;
    list_entry_t *le, *last;
    struct proc_struct *next = NULL;
    local_intr_save(intr_flag);
    {
        current->need_resched = 0;
ffffffffc0203882:	0000a897          	auipc	a7,0xa
ffffffffc0203886:	c4e8b883          	ld	a7,-946(a7) # ffffffffc020d4d0 <current>
ffffffffc020388a:	0008ac23          	sw	zero,24(a7)
        last = (current == idleproc) ? &proc_list : &(current->list_link);
ffffffffc020388e:	0000a517          	auipc	a0,0xa
ffffffffc0203892:	c4a53503          	ld	a0,-950(a0) # ffffffffc020d4d8 <idleproc>
ffffffffc0203896:	04a88e63          	beq	a7,a0,ffffffffc02038f2 <schedule+0x80>
ffffffffc020389a:	0c888693          	addi	a3,a7,200
ffffffffc020389e:	0000a617          	auipc	a2,0xa
ffffffffc02038a2:	bba60613          	addi	a2,a2,-1094 # ffffffffc020d458 <proc_list>
        le = last;
ffffffffc02038a6:	87b6                	mv	a5,a3
    struct proc_struct *next = NULL;
ffffffffc02038a8:	4581                	li	a1,0
        do {
            if ((le = list_next(le)) != &proc_list) {
                next = le2proc(le, list_link);
                if (next->state == PROC_RUNNABLE) {
ffffffffc02038aa:	4809                	li	a6,2
ffffffffc02038ac:	679c                	ld	a5,8(a5)
            if ((le = list_next(le)) != &proc_list) {
ffffffffc02038ae:	00c78863          	beq	a5,a2,ffffffffc02038be <schedule+0x4c>
                if (next->state == PROC_RUNNABLE) {
ffffffffc02038b2:	f387a703          	lw	a4,-200(a5)
                next = le2proc(le, list_link);
ffffffffc02038b6:	f3878593          	addi	a1,a5,-200
                if (next->state == PROC_RUNNABLE) {
ffffffffc02038ba:	03070163          	beq	a4,a6,ffffffffc02038dc <schedule+0x6a>
                    break;
                }
            }
        } while (le != last);
ffffffffc02038be:	fef697e3          	bne	a3,a5,ffffffffc02038ac <schedule+0x3a>
        if (next == NULL || next->state != PROC_RUNNABLE) {
ffffffffc02038c2:	ed89                	bnez	a1,ffffffffc02038dc <schedule+0x6a>
            next = idleproc;
        }
        next->runs ++;
ffffffffc02038c4:	451c                	lw	a5,8(a0)
ffffffffc02038c6:	2785                	addiw	a5,a5,1
ffffffffc02038c8:	c51c                	sw	a5,8(a0)
        if (next != current) {
ffffffffc02038ca:	00a88463          	beq	a7,a0,ffffffffc02038d2 <schedule+0x60>
            proc_run(next);
ffffffffc02038ce:	955ff0ef          	jal	ra,ffffffffc0203222 <proc_run>
    if (flag) {
ffffffffc02038d2:	e819                	bnez	s0,ffffffffc02038e8 <schedule+0x76>
        }
    }
    local_intr_restore(intr_flag);
}
ffffffffc02038d4:	60a2                	ld	ra,8(sp)
ffffffffc02038d6:	6402                	ld	s0,0(sp)
ffffffffc02038d8:	0141                	addi	sp,sp,16
ffffffffc02038da:	8082                	ret
        if (next == NULL || next->state != PROC_RUNNABLE) {
ffffffffc02038dc:	4198                	lw	a4,0(a1)
ffffffffc02038de:	4789                	li	a5,2
ffffffffc02038e0:	fef712e3          	bne	a4,a5,ffffffffc02038c4 <schedule+0x52>
ffffffffc02038e4:	852e                	mv	a0,a1
ffffffffc02038e6:	bff9                	j	ffffffffc02038c4 <schedule+0x52>
}
ffffffffc02038e8:	6402                	ld	s0,0(sp)
ffffffffc02038ea:	60a2                	ld	ra,8(sp)
ffffffffc02038ec:	0141                	addi	sp,sp,16
        intr_enable();
ffffffffc02038ee:	83cfd06f          	j	ffffffffc020092a <intr_enable>
        last = (current == idleproc) ? &proc_list : &(current->list_link);
ffffffffc02038f2:	0000a617          	auipc	a2,0xa
ffffffffc02038f6:	b6660613          	addi	a2,a2,-1178 # ffffffffc020d458 <proc_list>
ffffffffc02038fa:	86b2                	mv	a3,a2
ffffffffc02038fc:	b76d                	j	ffffffffc02038a6 <schedule+0x34>
        intr_disable();
ffffffffc02038fe:	832fd0ef          	jal	ra,ffffffffc0200930 <intr_disable>
        return 1;
ffffffffc0203902:	4405                	li	s0,1
ffffffffc0203904:	bfbd                	j	ffffffffc0203882 <schedule+0x10>

ffffffffc0203906 <hash32>:
 *
 * High bits are more random, so we use them.
 * */
uint32_t
hash32(uint32_t val, unsigned int bits) {
    uint32_t hash = val * GOLDEN_RATIO_PRIME_32;
ffffffffc0203906:	9e3707b7          	lui	a5,0x9e370
ffffffffc020390a:	2785                	addiw	a5,a5,1
ffffffffc020390c:	02a7853b          	mulw	a0,a5,a0
    return (hash >> (32 - bits));
ffffffffc0203910:	02000793          	li	a5,32
ffffffffc0203914:	9f8d                	subw	a5,a5,a1
}
ffffffffc0203916:	00f5553b          	srlw	a0,a0,a5
ffffffffc020391a:	8082                	ret

ffffffffc020391c <printnum>:
 * */
static void
printnum(void (*putch)(int, void*), void *putdat,
        unsigned long long num, unsigned base, int width, int padc) {
    unsigned long long result = num;
    unsigned mod = do_div(result, base);
ffffffffc020391c:	02069813          	slli	a6,a3,0x20
        unsigned long long num, unsigned base, int width, int padc) {
ffffffffc0203920:	7179                	addi	sp,sp,-48
    unsigned mod = do_div(result, base);
ffffffffc0203922:	02085813          	srli	a6,a6,0x20
        unsigned long long num, unsigned base, int width, int padc) {
ffffffffc0203926:	e052                	sd	s4,0(sp)
    unsigned mod = do_div(result, base);
ffffffffc0203928:	03067a33          	remu	s4,a2,a6
        unsigned long long num, unsigned base, int width, int padc) {
ffffffffc020392c:	f022                	sd	s0,32(sp)
ffffffffc020392e:	ec26                	sd	s1,24(sp)
ffffffffc0203930:	e84a                	sd	s2,16(sp)
ffffffffc0203932:	f406                	sd	ra,40(sp)
ffffffffc0203934:	e44e                	sd	s3,8(sp)
ffffffffc0203936:	84aa                	mv	s1,a0
ffffffffc0203938:	892e                	mv	s2,a1
    // first recursively print all preceding (more significant) digits
    if (num >= base) {
        printnum(putch, putdat, result, base, width - 1, padc);
    } else {
        // print any needed pad characters before first digit
        while (-- width > 0)
ffffffffc020393a:	fff7041b          	addiw	s0,a4,-1
    unsigned mod = do_div(result, base);
ffffffffc020393e:	2a01                	sext.w	s4,s4
    if (num >= base) {
ffffffffc0203940:	03067e63          	bgeu	a2,a6,ffffffffc020397c <printnum+0x60>
ffffffffc0203944:	89be                	mv	s3,a5
        while (-- width > 0)
ffffffffc0203946:	00805763          	blez	s0,ffffffffc0203954 <printnum+0x38>
ffffffffc020394a:	347d                	addiw	s0,s0,-1
            putch(padc, putdat);
ffffffffc020394c:	85ca                	mv	a1,s2
ffffffffc020394e:	854e                	mv	a0,s3
ffffffffc0203950:	9482                	jalr	s1
        while (-- width > 0)
ffffffffc0203952:	fc65                	bnez	s0,ffffffffc020394a <printnum+0x2e>
    }
    // then print this (the least significant) digit
    putch("0123456789abcdef"[mod], putdat);
ffffffffc0203954:	1a02                	slli	s4,s4,0x20
ffffffffc0203956:	00002797          	auipc	a5,0x2
ffffffffc020395a:	d3a78793          	addi	a5,a5,-710 # ffffffffc0205690 <best_fit_pmm_manager+0xad8>
ffffffffc020395e:	020a5a13          	srli	s4,s4,0x20
ffffffffc0203962:	9a3e                	add	s4,s4,a5
}
ffffffffc0203964:	7402                	ld	s0,32(sp)
    putch("0123456789abcdef"[mod], putdat);
ffffffffc0203966:	000a4503          	lbu	a0,0(s4)
}
ffffffffc020396a:	70a2                	ld	ra,40(sp)
ffffffffc020396c:	69a2                	ld	s3,8(sp)
ffffffffc020396e:	6a02                	ld	s4,0(sp)
    putch("0123456789abcdef"[mod], putdat);
ffffffffc0203970:	85ca                	mv	a1,s2
ffffffffc0203972:	87a6                	mv	a5,s1
}
ffffffffc0203974:	6942                	ld	s2,16(sp)
ffffffffc0203976:	64e2                	ld	s1,24(sp)
ffffffffc0203978:	6145                	addi	sp,sp,48
    putch("0123456789abcdef"[mod], putdat);
ffffffffc020397a:	8782                	jr	a5
        printnum(putch, putdat, result, base, width - 1, padc);
ffffffffc020397c:	03065633          	divu	a2,a2,a6
ffffffffc0203980:	8722                	mv	a4,s0
ffffffffc0203982:	f9bff0ef          	jal	ra,ffffffffc020391c <printnum>
ffffffffc0203986:	b7f9                	j	ffffffffc0203954 <printnum+0x38>

ffffffffc0203988 <vprintfmt>:
 *
 * Call this function if you are already dealing with a va_list.
 * Or you probably want printfmt() instead.
 * */
void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap) {
ffffffffc0203988:	7119                	addi	sp,sp,-128
ffffffffc020398a:	f4a6                	sd	s1,104(sp)
ffffffffc020398c:	f0ca                	sd	s2,96(sp)
ffffffffc020398e:	ecce                	sd	s3,88(sp)
ffffffffc0203990:	e8d2                	sd	s4,80(sp)
ffffffffc0203992:	e4d6                	sd	s5,72(sp)
ffffffffc0203994:	e0da                	sd	s6,64(sp)
ffffffffc0203996:	fc5e                	sd	s7,56(sp)
ffffffffc0203998:	f06a                	sd	s10,32(sp)
ffffffffc020399a:	fc86                	sd	ra,120(sp)
ffffffffc020399c:	f8a2                	sd	s0,112(sp)
ffffffffc020399e:	f862                	sd	s8,48(sp)
ffffffffc02039a0:	f466                	sd	s9,40(sp)
ffffffffc02039a2:	ec6e                	sd	s11,24(sp)
ffffffffc02039a4:	892a                	mv	s2,a0
ffffffffc02039a6:	84ae                	mv	s1,a1
ffffffffc02039a8:	8d32                	mv	s10,a2
ffffffffc02039aa:	8a36                	mv	s4,a3
    register int ch, err;
    unsigned long long num;
    int base, width, precision, lflag, altflag;

    while (1) {
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc02039ac:	02500993          	li	s3,37
            putch(ch, putdat);
        }

        // Process a %-escape sequence
        char padc = ' ';
        width = precision = -1;
ffffffffc02039b0:	5b7d                	li	s6,-1
ffffffffc02039b2:	00002a97          	auipc	s5,0x2
ffffffffc02039b6:	d0aa8a93          	addi	s5,s5,-758 # ffffffffc02056bc <best_fit_pmm_manager+0xb04>
        case 'e':
            err = va_arg(ap, int);
            if (err < 0) {
                err = -err;
            }
            if (err > MAXERROR || (p = error_string[err]) == NULL) {
ffffffffc02039ba:	00002b97          	auipc	s7,0x2
ffffffffc02039be:	edeb8b93          	addi	s7,s7,-290 # ffffffffc0205898 <error_string>
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc02039c2:	000d4503          	lbu	a0,0(s10)
ffffffffc02039c6:	001d0413          	addi	s0,s10,1
ffffffffc02039ca:	01350a63          	beq	a0,s3,ffffffffc02039de <vprintfmt+0x56>
            if (ch == '\0') {
ffffffffc02039ce:	c121                	beqz	a0,ffffffffc0203a0e <vprintfmt+0x86>
            putch(ch, putdat);
ffffffffc02039d0:	85a6                	mv	a1,s1
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc02039d2:	0405                	addi	s0,s0,1
            putch(ch, putdat);
ffffffffc02039d4:	9902                	jalr	s2
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc02039d6:	fff44503          	lbu	a0,-1(s0)
ffffffffc02039da:	ff351ae3          	bne	a0,s3,ffffffffc02039ce <vprintfmt+0x46>
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc02039de:	00044603          	lbu	a2,0(s0)
        char padc = ' ';
ffffffffc02039e2:	02000793          	li	a5,32
        lflag = altflag = 0;
ffffffffc02039e6:	4c81                	li	s9,0
ffffffffc02039e8:	4881                	li	a7,0
        width = precision = -1;
ffffffffc02039ea:	5c7d                	li	s8,-1
ffffffffc02039ec:	5dfd                	li	s11,-1
ffffffffc02039ee:	05500513          	li	a0,85
                if (ch < '0' || ch > '9') {
ffffffffc02039f2:	4825                	li	a6,9
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc02039f4:	fdd6059b          	addiw	a1,a2,-35
ffffffffc02039f8:	0ff5f593          	zext.b	a1,a1
ffffffffc02039fc:	00140d13          	addi	s10,s0,1
ffffffffc0203a00:	04b56263          	bltu	a0,a1,ffffffffc0203a44 <vprintfmt+0xbc>
ffffffffc0203a04:	058a                	slli	a1,a1,0x2
ffffffffc0203a06:	95d6                	add	a1,a1,s5
ffffffffc0203a08:	4194                	lw	a3,0(a1)
ffffffffc0203a0a:	96d6                	add	a3,a3,s5
ffffffffc0203a0c:	8682                	jr	a3
            for (fmt --; fmt[-1] != '%'; fmt --)
                /* do nothing */;
            break;
        }
    }
}
ffffffffc0203a0e:	70e6                	ld	ra,120(sp)
ffffffffc0203a10:	7446                	ld	s0,112(sp)
ffffffffc0203a12:	74a6                	ld	s1,104(sp)
ffffffffc0203a14:	7906                	ld	s2,96(sp)
ffffffffc0203a16:	69e6                	ld	s3,88(sp)
ffffffffc0203a18:	6a46                	ld	s4,80(sp)
ffffffffc0203a1a:	6aa6                	ld	s5,72(sp)
ffffffffc0203a1c:	6b06                	ld	s6,64(sp)
ffffffffc0203a1e:	7be2                	ld	s7,56(sp)
ffffffffc0203a20:	7c42                	ld	s8,48(sp)
ffffffffc0203a22:	7ca2                	ld	s9,40(sp)
ffffffffc0203a24:	7d02                	ld	s10,32(sp)
ffffffffc0203a26:	6de2                	ld	s11,24(sp)
ffffffffc0203a28:	6109                	addi	sp,sp,128
ffffffffc0203a2a:	8082                	ret
            padc = '0';
ffffffffc0203a2c:	87b2                	mv	a5,a2
            goto reswitch;
ffffffffc0203a2e:	00144603          	lbu	a2,1(s0)
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0203a32:	846a                	mv	s0,s10
ffffffffc0203a34:	00140d13          	addi	s10,s0,1
ffffffffc0203a38:	fdd6059b          	addiw	a1,a2,-35
ffffffffc0203a3c:	0ff5f593          	zext.b	a1,a1
ffffffffc0203a40:	fcb572e3          	bgeu	a0,a1,ffffffffc0203a04 <vprintfmt+0x7c>
            putch('%', putdat);
ffffffffc0203a44:	85a6                	mv	a1,s1
ffffffffc0203a46:	02500513          	li	a0,37
ffffffffc0203a4a:	9902                	jalr	s2
            for (fmt --; fmt[-1] != '%'; fmt --)
ffffffffc0203a4c:	fff44783          	lbu	a5,-1(s0)
ffffffffc0203a50:	8d22                	mv	s10,s0
ffffffffc0203a52:	f73788e3          	beq	a5,s3,ffffffffc02039c2 <vprintfmt+0x3a>
ffffffffc0203a56:	ffed4783          	lbu	a5,-2(s10)
ffffffffc0203a5a:	1d7d                	addi	s10,s10,-1
ffffffffc0203a5c:	ff379de3          	bne	a5,s3,ffffffffc0203a56 <vprintfmt+0xce>
ffffffffc0203a60:	b78d                	j	ffffffffc02039c2 <vprintfmt+0x3a>
                precision = precision * 10 + ch - '0';
ffffffffc0203a62:	fd060c1b          	addiw	s8,a2,-48
                ch = *fmt;
ffffffffc0203a66:	00144603          	lbu	a2,1(s0)
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0203a6a:	846a                	mv	s0,s10
                if (ch < '0' || ch > '9') {
ffffffffc0203a6c:	fd06069b          	addiw	a3,a2,-48
                ch = *fmt;
ffffffffc0203a70:	0006059b          	sext.w	a1,a2
                if (ch < '0' || ch > '9') {
ffffffffc0203a74:	02d86463          	bltu	a6,a3,ffffffffc0203a9c <vprintfmt+0x114>
                ch = *fmt;
ffffffffc0203a78:	00144603          	lbu	a2,1(s0)
                precision = precision * 10 + ch - '0';
ffffffffc0203a7c:	002c169b          	slliw	a3,s8,0x2
ffffffffc0203a80:	0186873b          	addw	a4,a3,s8
ffffffffc0203a84:	0017171b          	slliw	a4,a4,0x1
ffffffffc0203a88:	9f2d                	addw	a4,a4,a1
                if (ch < '0' || ch > '9') {
ffffffffc0203a8a:	fd06069b          	addiw	a3,a2,-48
            for (precision = 0; ; ++ fmt) {
ffffffffc0203a8e:	0405                	addi	s0,s0,1
                precision = precision * 10 + ch - '0';
ffffffffc0203a90:	fd070c1b          	addiw	s8,a4,-48
                ch = *fmt;
ffffffffc0203a94:	0006059b          	sext.w	a1,a2
                if (ch < '0' || ch > '9') {
ffffffffc0203a98:	fed870e3          	bgeu	a6,a3,ffffffffc0203a78 <vprintfmt+0xf0>
            if (width < 0)
ffffffffc0203a9c:	f40ddce3          	bgez	s11,ffffffffc02039f4 <vprintfmt+0x6c>
                width = precision, precision = -1;
ffffffffc0203aa0:	8de2                	mv	s11,s8
ffffffffc0203aa2:	5c7d                	li	s8,-1
ffffffffc0203aa4:	bf81                	j	ffffffffc02039f4 <vprintfmt+0x6c>
            if (width < 0)
ffffffffc0203aa6:	fffdc693          	not	a3,s11
ffffffffc0203aaa:	96fd                	srai	a3,a3,0x3f
ffffffffc0203aac:	00ddfdb3          	and	s11,s11,a3
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0203ab0:	00144603          	lbu	a2,1(s0)
ffffffffc0203ab4:	2d81                	sext.w	s11,s11
ffffffffc0203ab6:	846a                	mv	s0,s10
            goto reswitch;
ffffffffc0203ab8:	bf35                	j	ffffffffc02039f4 <vprintfmt+0x6c>
            precision = va_arg(ap, int);
ffffffffc0203aba:	000a2c03          	lw	s8,0(s4)
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0203abe:	00144603          	lbu	a2,1(s0)
            precision = va_arg(ap, int);
ffffffffc0203ac2:	0a21                	addi	s4,s4,8
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0203ac4:	846a                	mv	s0,s10
            goto process_precision;
ffffffffc0203ac6:	bfd9                	j	ffffffffc0203a9c <vprintfmt+0x114>
    if (lflag >= 2) {
ffffffffc0203ac8:	4705                	li	a4,1
            precision = va_arg(ap, int);
ffffffffc0203aca:	008a0593          	addi	a1,s4,8
    if (lflag >= 2) {
ffffffffc0203ace:	01174463          	blt	a4,a7,ffffffffc0203ad6 <vprintfmt+0x14e>
    else if (lflag) {
ffffffffc0203ad2:	1a088e63          	beqz	a7,ffffffffc0203c8e <vprintfmt+0x306>
        return va_arg(*ap, unsigned long);
ffffffffc0203ad6:	000a3603          	ld	a2,0(s4)
ffffffffc0203ada:	46c1                	li	a3,16
ffffffffc0203adc:	8a2e                	mv	s4,a1
            printnum(putch, putdat, num, base, width, padc);
ffffffffc0203ade:	2781                	sext.w	a5,a5
ffffffffc0203ae0:	876e                	mv	a4,s11
ffffffffc0203ae2:	85a6                	mv	a1,s1
ffffffffc0203ae4:	854a                	mv	a0,s2
ffffffffc0203ae6:	e37ff0ef          	jal	ra,ffffffffc020391c <printnum>
            break;
ffffffffc0203aea:	bde1                	j	ffffffffc02039c2 <vprintfmt+0x3a>
            putch(va_arg(ap, int), putdat);
ffffffffc0203aec:	000a2503          	lw	a0,0(s4)
ffffffffc0203af0:	85a6                	mv	a1,s1
ffffffffc0203af2:	0a21                	addi	s4,s4,8
ffffffffc0203af4:	9902                	jalr	s2
            break;
ffffffffc0203af6:	b5f1                	j	ffffffffc02039c2 <vprintfmt+0x3a>
    if (lflag >= 2) {
ffffffffc0203af8:	4705                	li	a4,1
            precision = va_arg(ap, int);
ffffffffc0203afa:	008a0593          	addi	a1,s4,8
    if (lflag >= 2) {
ffffffffc0203afe:	01174463          	blt	a4,a7,ffffffffc0203b06 <vprintfmt+0x17e>
    else if (lflag) {
ffffffffc0203b02:	18088163          	beqz	a7,ffffffffc0203c84 <vprintfmt+0x2fc>
        return va_arg(*ap, unsigned long);
ffffffffc0203b06:	000a3603          	ld	a2,0(s4)
ffffffffc0203b0a:	46a9                	li	a3,10
ffffffffc0203b0c:	8a2e                	mv	s4,a1
ffffffffc0203b0e:	bfc1                	j	ffffffffc0203ade <vprintfmt+0x156>
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0203b10:	00144603          	lbu	a2,1(s0)
            altflag = 1;
ffffffffc0203b14:	4c85                	li	s9,1
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0203b16:	846a                	mv	s0,s10
            goto reswitch;
ffffffffc0203b18:	bdf1                	j	ffffffffc02039f4 <vprintfmt+0x6c>
            putch(ch, putdat);
ffffffffc0203b1a:	85a6                	mv	a1,s1
ffffffffc0203b1c:	02500513          	li	a0,37
ffffffffc0203b20:	9902                	jalr	s2
            break;
ffffffffc0203b22:	b545                	j	ffffffffc02039c2 <vprintfmt+0x3a>
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0203b24:	00144603          	lbu	a2,1(s0)
            lflag ++;
ffffffffc0203b28:	2885                	addiw	a7,a7,1
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0203b2a:	846a                	mv	s0,s10
            goto reswitch;
ffffffffc0203b2c:	b5e1                	j	ffffffffc02039f4 <vprintfmt+0x6c>
    if (lflag >= 2) {
ffffffffc0203b2e:	4705                	li	a4,1
            precision = va_arg(ap, int);
ffffffffc0203b30:	008a0593          	addi	a1,s4,8
    if (lflag >= 2) {
ffffffffc0203b34:	01174463          	blt	a4,a7,ffffffffc0203b3c <vprintfmt+0x1b4>
    else if (lflag) {
ffffffffc0203b38:	14088163          	beqz	a7,ffffffffc0203c7a <vprintfmt+0x2f2>
        return va_arg(*ap, unsigned long);
ffffffffc0203b3c:	000a3603          	ld	a2,0(s4)
ffffffffc0203b40:	46a1                	li	a3,8
ffffffffc0203b42:	8a2e                	mv	s4,a1
ffffffffc0203b44:	bf69                	j	ffffffffc0203ade <vprintfmt+0x156>
            putch('0', putdat);
ffffffffc0203b46:	03000513          	li	a0,48
ffffffffc0203b4a:	85a6                	mv	a1,s1
ffffffffc0203b4c:	e03e                	sd	a5,0(sp)
ffffffffc0203b4e:	9902                	jalr	s2
            putch('x', putdat);
ffffffffc0203b50:	85a6                	mv	a1,s1
ffffffffc0203b52:	07800513          	li	a0,120
ffffffffc0203b56:	9902                	jalr	s2
            num = (unsigned long long)(uintptr_t)va_arg(ap, void *);
ffffffffc0203b58:	0a21                	addi	s4,s4,8
            goto number;
ffffffffc0203b5a:	6782                	ld	a5,0(sp)
ffffffffc0203b5c:	46c1                	li	a3,16
            num = (unsigned long long)(uintptr_t)va_arg(ap, void *);
ffffffffc0203b5e:	ff8a3603          	ld	a2,-8(s4)
            goto number;
ffffffffc0203b62:	bfb5                	j	ffffffffc0203ade <vprintfmt+0x156>
            if ((p = va_arg(ap, char *)) == NULL) {
ffffffffc0203b64:	000a3403          	ld	s0,0(s4)
ffffffffc0203b68:	008a0713          	addi	a4,s4,8
ffffffffc0203b6c:	e03a                	sd	a4,0(sp)
ffffffffc0203b6e:	14040263          	beqz	s0,ffffffffc0203cb2 <vprintfmt+0x32a>
            if (width > 0 && padc != '-') {
ffffffffc0203b72:	0fb05763          	blez	s11,ffffffffc0203c60 <vprintfmt+0x2d8>
ffffffffc0203b76:	02d00693          	li	a3,45
ffffffffc0203b7a:	0cd79163          	bne	a5,a3,ffffffffc0203c3c <vprintfmt+0x2b4>
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0203b7e:	00044783          	lbu	a5,0(s0)
ffffffffc0203b82:	0007851b          	sext.w	a0,a5
ffffffffc0203b86:	cf85                	beqz	a5,ffffffffc0203bbe <vprintfmt+0x236>
ffffffffc0203b88:	00140a13          	addi	s4,s0,1
                if (altflag && (ch < ' ' || ch > '~')) {
ffffffffc0203b8c:	05e00413          	li	s0,94
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0203b90:	000c4563          	bltz	s8,ffffffffc0203b9a <vprintfmt+0x212>
ffffffffc0203b94:	3c7d                	addiw	s8,s8,-1
ffffffffc0203b96:	036c0263          	beq	s8,s6,ffffffffc0203bba <vprintfmt+0x232>
                    putch('?', putdat);
ffffffffc0203b9a:	85a6                	mv	a1,s1
                if (altflag && (ch < ' ' || ch > '~')) {
ffffffffc0203b9c:	0e0c8e63          	beqz	s9,ffffffffc0203c98 <vprintfmt+0x310>
ffffffffc0203ba0:	3781                	addiw	a5,a5,-32
ffffffffc0203ba2:	0ef47b63          	bgeu	s0,a5,ffffffffc0203c98 <vprintfmt+0x310>
                    putch('?', putdat);
ffffffffc0203ba6:	03f00513          	li	a0,63
ffffffffc0203baa:	9902                	jalr	s2
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0203bac:	000a4783          	lbu	a5,0(s4)
ffffffffc0203bb0:	3dfd                	addiw	s11,s11,-1
ffffffffc0203bb2:	0a05                	addi	s4,s4,1
ffffffffc0203bb4:	0007851b          	sext.w	a0,a5
ffffffffc0203bb8:	ffe1                	bnez	a5,ffffffffc0203b90 <vprintfmt+0x208>
            for (; width > 0; width --) {
ffffffffc0203bba:	01b05963          	blez	s11,ffffffffc0203bcc <vprintfmt+0x244>
ffffffffc0203bbe:	3dfd                	addiw	s11,s11,-1
                putch(' ', putdat);
ffffffffc0203bc0:	85a6                	mv	a1,s1
ffffffffc0203bc2:	02000513          	li	a0,32
ffffffffc0203bc6:	9902                	jalr	s2
            for (; width > 0; width --) {
ffffffffc0203bc8:	fe0d9be3          	bnez	s11,ffffffffc0203bbe <vprintfmt+0x236>
            if ((p = va_arg(ap, char *)) == NULL) {
ffffffffc0203bcc:	6a02                	ld	s4,0(sp)
ffffffffc0203bce:	bbd5                	j	ffffffffc02039c2 <vprintfmt+0x3a>
    if (lflag >= 2) {
ffffffffc0203bd0:	4705                	li	a4,1
            precision = va_arg(ap, int);
ffffffffc0203bd2:	008a0c93          	addi	s9,s4,8
    if (lflag >= 2) {
ffffffffc0203bd6:	01174463          	blt	a4,a7,ffffffffc0203bde <vprintfmt+0x256>
    else if (lflag) {
ffffffffc0203bda:	08088d63          	beqz	a7,ffffffffc0203c74 <vprintfmt+0x2ec>
        return va_arg(*ap, long);
ffffffffc0203bde:	000a3403          	ld	s0,0(s4)
            if ((long long)num < 0) {
ffffffffc0203be2:	0a044d63          	bltz	s0,ffffffffc0203c9c <vprintfmt+0x314>
            num = getint(&ap, lflag);
ffffffffc0203be6:	8622                	mv	a2,s0
ffffffffc0203be8:	8a66                	mv	s4,s9
ffffffffc0203bea:	46a9                	li	a3,10
ffffffffc0203bec:	bdcd                	j	ffffffffc0203ade <vprintfmt+0x156>
            err = va_arg(ap, int);
ffffffffc0203bee:	000a2783          	lw	a5,0(s4)
            if (err > MAXERROR || (p = error_string[err]) == NULL) {
ffffffffc0203bf2:	4719                	li	a4,6
            err = va_arg(ap, int);
ffffffffc0203bf4:	0a21                	addi	s4,s4,8
            if (err < 0) {
ffffffffc0203bf6:	41f7d69b          	sraiw	a3,a5,0x1f
ffffffffc0203bfa:	8fb5                	xor	a5,a5,a3
ffffffffc0203bfc:	40d786bb          	subw	a3,a5,a3
            if (err > MAXERROR || (p = error_string[err]) == NULL) {
ffffffffc0203c00:	02d74163          	blt	a4,a3,ffffffffc0203c22 <vprintfmt+0x29a>
ffffffffc0203c04:	00369793          	slli	a5,a3,0x3
ffffffffc0203c08:	97de                	add	a5,a5,s7
ffffffffc0203c0a:	639c                	ld	a5,0(a5)
ffffffffc0203c0c:	cb99                	beqz	a5,ffffffffc0203c22 <vprintfmt+0x29a>
                printfmt(putch, putdat, "%s", p);
ffffffffc0203c0e:	86be                	mv	a3,a5
ffffffffc0203c10:	00000617          	auipc	a2,0x0
ffffffffc0203c14:	21860613          	addi	a2,a2,536 # ffffffffc0203e28 <etext+0x2e>
ffffffffc0203c18:	85a6                	mv	a1,s1
ffffffffc0203c1a:	854a                	mv	a0,s2
ffffffffc0203c1c:	0ce000ef          	jal	ra,ffffffffc0203cea <printfmt>
ffffffffc0203c20:	b34d                	j	ffffffffc02039c2 <vprintfmt+0x3a>
                printfmt(putch, putdat, "error %d", err);
ffffffffc0203c22:	00002617          	auipc	a2,0x2
ffffffffc0203c26:	a8e60613          	addi	a2,a2,-1394 # ffffffffc02056b0 <best_fit_pmm_manager+0xaf8>
ffffffffc0203c2a:	85a6                	mv	a1,s1
ffffffffc0203c2c:	854a                	mv	a0,s2
ffffffffc0203c2e:	0bc000ef          	jal	ra,ffffffffc0203cea <printfmt>
ffffffffc0203c32:	bb41                	j	ffffffffc02039c2 <vprintfmt+0x3a>
                p = "(null)";
ffffffffc0203c34:	00002417          	auipc	s0,0x2
ffffffffc0203c38:	a7440413          	addi	s0,s0,-1420 # ffffffffc02056a8 <best_fit_pmm_manager+0xaf0>
                for (width -= strnlen(p, precision); width > 0; width --) {
ffffffffc0203c3c:	85e2                	mv	a1,s8
ffffffffc0203c3e:	8522                	mv	a0,s0
ffffffffc0203c40:	e43e                	sd	a5,8(sp)
ffffffffc0203c42:	0e2000ef          	jal	ra,ffffffffc0203d24 <strnlen>
ffffffffc0203c46:	40ad8dbb          	subw	s11,s11,a0
ffffffffc0203c4a:	01b05b63          	blez	s11,ffffffffc0203c60 <vprintfmt+0x2d8>
                    putch(padc, putdat);
ffffffffc0203c4e:	67a2                	ld	a5,8(sp)
ffffffffc0203c50:	00078a1b          	sext.w	s4,a5
                for (width -= strnlen(p, precision); width > 0; width --) {
ffffffffc0203c54:	3dfd                	addiw	s11,s11,-1
                    putch(padc, putdat);
ffffffffc0203c56:	85a6                	mv	a1,s1
ffffffffc0203c58:	8552                	mv	a0,s4
ffffffffc0203c5a:	9902                	jalr	s2
                for (width -= strnlen(p, precision); width > 0; width --) {
ffffffffc0203c5c:	fe0d9ce3          	bnez	s11,ffffffffc0203c54 <vprintfmt+0x2cc>
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0203c60:	00044783          	lbu	a5,0(s0)
ffffffffc0203c64:	00140a13          	addi	s4,s0,1
ffffffffc0203c68:	0007851b          	sext.w	a0,a5
ffffffffc0203c6c:	d3a5                	beqz	a5,ffffffffc0203bcc <vprintfmt+0x244>
                if (altflag && (ch < ' ' || ch > '~')) {
ffffffffc0203c6e:	05e00413          	li	s0,94
ffffffffc0203c72:	bf39                	j	ffffffffc0203b90 <vprintfmt+0x208>
        return va_arg(*ap, int);
ffffffffc0203c74:	000a2403          	lw	s0,0(s4)
ffffffffc0203c78:	b7ad                	j	ffffffffc0203be2 <vprintfmt+0x25a>
        return va_arg(*ap, unsigned int);
ffffffffc0203c7a:	000a6603          	lwu	a2,0(s4)
ffffffffc0203c7e:	46a1                	li	a3,8
ffffffffc0203c80:	8a2e                	mv	s4,a1
ffffffffc0203c82:	bdb1                	j	ffffffffc0203ade <vprintfmt+0x156>
ffffffffc0203c84:	000a6603          	lwu	a2,0(s4)
ffffffffc0203c88:	46a9                	li	a3,10
ffffffffc0203c8a:	8a2e                	mv	s4,a1
ffffffffc0203c8c:	bd89                	j	ffffffffc0203ade <vprintfmt+0x156>
ffffffffc0203c8e:	000a6603          	lwu	a2,0(s4)
ffffffffc0203c92:	46c1                	li	a3,16
ffffffffc0203c94:	8a2e                	mv	s4,a1
ffffffffc0203c96:	b5a1                	j	ffffffffc0203ade <vprintfmt+0x156>
                    putch(ch, putdat);
ffffffffc0203c98:	9902                	jalr	s2
ffffffffc0203c9a:	bf09                	j	ffffffffc0203bac <vprintfmt+0x224>
                putch('-', putdat);
ffffffffc0203c9c:	85a6                	mv	a1,s1
ffffffffc0203c9e:	02d00513          	li	a0,45
ffffffffc0203ca2:	e03e                	sd	a5,0(sp)
ffffffffc0203ca4:	9902                	jalr	s2
                num = -(long long)num;
ffffffffc0203ca6:	6782                	ld	a5,0(sp)
ffffffffc0203ca8:	8a66                	mv	s4,s9
ffffffffc0203caa:	40800633          	neg	a2,s0
ffffffffc0203cae:	46a9                	li	a3,10
ffffffffc0203cb0:	b53d                	j	ffffffffc0203ade <vprintfmt+0x156>
            if (width > 0 && padc != '-') {
ffffffffc0203cb2:	03b05163          	blez	s11,ffffffffc0203cd4 <vprintfmt+0x34c>
ffffffffc0203cb6:	02d00693          	li	a3,45
ffffffffc0203cba:	f6d79de3          	bne	a5,a3,ffffffffc0203c34 <vprintfmt+0x2ac>
                p = "(null)";
ffffffffc0203cbe:	00002417          	auipc	s0,0x2
ffffffffc0203cc2:	9ea40413          	addi	s0,s0,-1558 # ffffffffc02056a8 <best_fit_pmm_manager+0xaf0>
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0203cc6:	02800793          	li	a5,40
ffffffffc0203cca:	02800513          	li	a0,40
ffffffffc0203cce:	00140a13          	addi	s4,s0,1
ffffffffc0203cd2:	bd6d                	j	ffffffffc0203b8c <vprintfmt+0x204>
ffffffffc0203cd4:	00002a17          	auipc	s4,0x2
ffffffffc0203cd8:	9d5a0a13          	addi	s4,s4,-1579 # ffffffffc02056a9 <best_fit_pmm_manager+0xaf1>
ffffffffc0203cdc:	02800513          	li	a0,40
ffffffffc0203ce0:	02800793          	li	a5,40
                if (altflag && (ch < ' ' || ch > '~')) {
ffffffffc0203ce4:	05e00413          	li	s0,94
ffffffffc0203ce8:	b565                	j	ffffffffc0203b90 <vprintfmt+0x208>

ffffffffc0203cea <printfmt>:
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
ffffffffc0203cea:	715d                	addi	sp,sp,-80
    va_start(ap, fmt);
ffffffffc0203cec:	02810313          	addi	t1,sp,40
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
ffffffffc0203cf0:	f436                	sd	a3,40(sp)
    vprintfmt(putch, putdat, fmt, ap);
ffffffffc0203cf2:	869a                	mv	a3,t1
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
ffffffffc0203cf4:	ec06                	sd	ra,24(sp)
ffffffffc0203cf6:	f83a                	sd	a4,48(sp)
ffffffffc0203cf8:	fc3e                	sd	a5,56(sp)
ffffffffc0203cfa:	e0c2                	sd	a6,64(sp)
ffffffffc0203cfc:	e4c6                	sd	a7,72(sp)
    va_start(ap, fmt);
ffffffffc0203cfe:	e41a                	sd	t1,8(sp)
    vprintfmt(putch, putdat, fmt, ap);
ffffffffc0203d00:	c89ff0ef          	jal	ra,ffffffffc0203988 <vprintfmt>
}
ffffffffc0203d04:	60e2                	ld	ra,24(sp)
ffffffffc0203d06:	6161                	addi	sp,sp,80
ffffffffc0203d08:	8082                	ret

ffffffffc0203d0a <strlen>:
 * The strlen() function returns the length of string @s.
 * */
size_t
strlen(const char *s) {
    size_t cnt = 0;
    while (*s ++ != '\0') {
ffffffffc0203d0a:	00054783          	lbu	a5,0(a0)
strlen(const char *s) {
ffffffffc0203d0e:	872a                	mv	a4,a0
    size_t cnt = 0;
ffffffffc0203d10:	4501                	li	a0,0
    while (*s ++ != '\0') {
ffffffffc0203d12:	cb81                	beqz	a5,ffffffffc0203d22 <strlen+0x18>
        cnt ++;
ffffffffc0203d14:	0505                	addi	a0,a0,1
    while (*s ++ != '\0') {
ffffffffc0203d16:	00a707b3          	add	a5,a4,a0
ffffffffc0203d1a:	0007c783          	lbu	a5,0(a5)
ffffffffc0203d1e:	fbfd                	bnez	a5,ffffffffc0203d14 <strlen+0xa>
ffffffffc0203d20:	8082                	ret
    }
    return cnt;
}
ffffffffc0203d22:	8082                	ret

ffffffffc0203d24 <strnlen>:
 * @len if there is no '\0' character among the first @len characters
 * pointed by @s.
 * */
size_t
strnlen(const char *s, size_t len) {
    size_t cnt = 0;
ffffffffc0203d24:	4781                	li	a5,0
    while (cnt < len && *s ++ != '\0') {
ffffffffc0203d26:	e589                	bnez	a1,ffffffffc0203d30 <strnlen+0xc>
ffffffffc0203d28:	a811                	j	ffffffffc0203d3c <strnlen+0x18>
        cnt ++;
ffffffffc0203d2a:	0785                	addi	a5,a5,1
    while (cnt < len && *s ++ != '\0') {
ffffffffc0203d2c:	00f58863          	beq	a1,a5,ffffffffc0203d3c <strnlen+0x18>
ffffffffc0203d30:	00f50733          	add	a4,a0,a5
ffffffffc0203d34:	00074703          	lbu	a4,0(a4)
ffffffffc0203d38:	fb6d                	bnez	a4,ffffffffc0203d2a <strnlen+0x6>
ffffffffc0203d3a:	85be                	mv	a1,a5
    }
    return cnt;
}
ffffffffc0203d3c:	852e                	mv	a0,a1
ffffffffc0203d3e:	8082                	ret

ffffffffc0203d40 <strcpy>:
char *
strcpy(char *dst, const char *src) {
#ifdef __HAVE_ARCH_STRCPY
    return __strcpy(dst, src);
#else
    char *p = dst;
ffffffffc0203d40:	87aa                	mv	a5,a0
    while ((*p ++ = *src ++) != '\0')
ffffffffc0203d42:	0005c703          	lbu	a4,0(a1)
ffffffffc0203d46:	0785                	addi	a5,a5,1
ffffffffc0203d48:	0585                	addi	a1,a1,1
ffffffffc0203d4a:	fee78fa3          	sb	a4,-1(a5)
ffffffffc0203d4e:	fb75                	bnez	a4,ffffffffc0203d42 <strcpy+0x2>
        /* nothing */;
    return dst;
#endif /* __HAVE_ARCH_STRCPY */
}
ffffffffc0203d50:	8082                	ret

ffffffffc0203d52 <strcmp>:
int
strcmp(const char *s1, const char *s2) {
#ifdef __HAVE_ARCH_STRCMP
    return __strcmp(s1, s2);
#else
    while (*s1 != '\0' && *s1 == *s2) {
ffffffffc0203d52:	00054783          	lbu	a5,0(a0)
        s1 ++, s2 ++;
    }
    return (int)((unsigned char)*s1 - (unsigned char)*s2);
ffffffffc0203d56:	0005c703          	lbu	a4,0(a1)
    while (*s1 != '\0' && *s1 == *s2) {
ffffffffc0203d5a:	cb89                	beqz	a5,ffffffffc0203d6c <strcmp+0x1a>
        s1 ++, s2 ++;
ffffffffc0203d5c:	0505                	addi	a0,a0,1
ffffffffc0203d5e:	0585                	addi	a1,a1,1
    while (*s1 != '\0' && *s1 == *s2) {
ffffffffc0203d60:	fee789e3          	beq	a5,a4,ffffffffc0203d52 <strcmp>
    return (int)((unsigned char)*s1 - (unsigned char)*s2);
ffffffffc0203d64:	0007851b          	sext.w	a0,a5
#endif /* __HAVE_ARCH_STRCMP */
}
ffffffffc0203d68:	9d19                	subw	a0,a0,a4
ffffffffc0203d6a:	8082                	ret
ffffffffc0203d6c:	4501                	li	a0,0
ffffffffc0203d6e:	bfed                	j	ffffffffc0203d68 <strcmp+0x16>

ffffffffc0203d70 <strncmp>:
 * the characters differ, until a terminating null-character is reached, or
 * until @n characters match in both strings, whichever happens first.
 * */
int
strncmp(const char *s1, const char *s2, size_t n) {
    while (n > 0 && *s1 != '\0' && *s1 == *s2) {
ffffffffc0203d70:	c20d                	beqz	a2,ffffffffc0203d92 <strncmp+0x22>
ffffffffc0203d72:	962e                	add	a2,a2,a1
ffffffffc0203d74:	a031                	j	ffffffffc0203d80 <strncmp+0x10>
        n --, s1 ++, s2 ++;
ffffffffc0203d76:	0505                	addi	a0,a0,1
    while (n > 0 && *s1 != '\0' && *s1 == *s2) {
ffffffffc0203d78:	00e79a63          	bne	a5,a4,ffffffffc0203d8c <strncmp+0x1c>
ffffffffc0203d7c:	00b60b63          	beq	a2,a1,ffffffffc0203d92 <strncmp+0x22>
ffffffffc0203d80:	00054783          	lbu	a5,0(a0)
        n --, s1 ++, s2 ++;
ffffffffc0203d84:	0585                	addi	a1,a1,1
    while (n > 0 && *s1 != '\0' && *s1 == *s2) {
ffffffffc0203d86:	fff5c703          	lbu	a4,-1(a1)
ffffffffc0203d8a:	f7f5                	bnez	a5,ffffffffc0203d76 <strncmp+0x6>
    }
    return (n == 0) ? 0 : (int)((unsigned char)*s1 - (unsigned char)*s2);
ffffffffc0203d8c:	40e7853b          	subw	a0,a5,a4
}
ffffffffc0203d90:	8082                	ret
    return (n == 0) ? 0 : (int)((unsigned char)*s1 - (unsigned char)*s2);
ffffffffc0203d92:	4501                	li	a0,0
ffffffffc0203d94:	8082                	ret

ffffffffc0203d96 <strchr>:
 * The strchr() function returns a pointer to the first occurrence of
 * character in @s. If the value is not found, the function returns 'NULL'.
 * */
char *
strchr(const char *s, char c) {
    while (*s != '\0') {
ffffffffc0203d96:	00054783          	lbu	a5,0(a0)
ffffffffc0203d9a:	c799                	beqz	a5,ffffffffc0203da8 <strchr+0x12>
        if (*s == c) {
ffffffffc0203d9c:	00f58763          	beq	a1,a5,ffffffffc0203daa <strchr+0x14>
    while (*s != '\0') {
ffffffffc0203da0:	00154783          	lbu	a5,1(a0)
            return (char *)s;
        }
        s ++;
ffffffffc0203da4:	0505                	addi	a0,a0,1
    while (*s != '\0') {
ffffffffc0203da6:	fbfd                	bnez	a5,ffffffffc0203d9c <strchr+0x6>
    }
    return NULL;
ffffffffc0203da8:	4501                	li	a0,0
}
ffffffffc0203daa:	8082                	ret

ffffffffc0203dac <memset>:
memset(void *s, char c, size_t n) {
#ifdef __HAVE_ARCH_MEMSET
    return __memset(s, c, n);
#else
    char *p = s;
    while (n -- > 0) {
ffffffffc0203dac:	ca01                	beqz	a2,ffffffffc0203dbc <memset+0x10>
ffffffffc0203dae:	962a                	add	a2,a2,a0
    char *p = s;
ffffffffc0203db0:	87aa                	mv	a5,a0
        *p ++ = c;
ffffffffc0203db2:	0785                	addi	a5,a5,1
ffffffffc0203db4:	feb78fa3          	sb	a1,-1(a5)
    while (n -- > 0) {
ffffffffc0203db8:	fec79de3          	bne	a5,a2,ffffffffc0203db2 <memset+0x6>
    }
    return s;
#endif /* __HAVE_ARCH_MEMSET */
}
ffffffffc0203dbc:	8082                	ret

ffffffffc0203dbe <memcpy>:
#ifdef __HAVE_ARCH_MEMCPY
    return __memcpy(dst, src, n);
#else
    const char *s = src;
    char *d = dst;
    while (n -- > 0) {
ffffffffc0203dbe:	ca19                	beqz	a2,ffffffffc0203dd4 <memcpy+0x16>
ffffffffc0203dc0:	962e                	add	a2,a2,a1
    char *d = dst;
ffffffffc0203dc2:	87aa                	mv	a5,a0
        *d ++ = *s ++;
ffffffffc0203dc4:	0005c703          	lbu	a4,0(a1)
ffffffffc0203dc8:	0585                	addi	a1,a1,1
ffffffffc0203dca:	0785                	addi	a5,a5,1
ffffffffc0203dcc:	fee78fa3          	sb	a4,-1(a5)
    while (n -- > 0) {
ffffffffc0203dd0:	fec59ae3          	bne	a1,a2,ffffffffc0203dc4 <memcpy+0x6>
    }
    return dst;
#endif /* __HAVE_ARCH_MEMCPY */
}
ffffffffc0203dd4:	8082                	ret

ffffffffc0203dd6 <memcmp>:
 * */
int
memcmp(const void *v1, const void *v2, size_t n) {
    const char *s1 = (const char *)v1;
    const char *s2 = (const char *)v2;
    while (n -- > 0) {
ffffffffc0203dd6:	c205                	beqz	a2,ffffffffc0203df6 <memcmp+0x20>
ffffffffc0203dd8:	962e                	add	a2,a2,a1
ffffffffc0203dda:	a019                	j	ffffffffc0203de0 <memcmp+0xa>
ffffffffc0203ddc:	00c58d63          	beq	a1,a2,ffffffffc0203df6 <memcmp+0x20>
        if (*s1 != *s2) {
ffffffffc0203de0:	00054783          	lbu	a5,0(a0)
ffffffffc0203de4:	0005c703          	lbu	a4,0(a1)
            return (int)((unsigned char)*s1 - (unsigned char)*s2);
        }
        s1 ++, s2 ++;
ffffffffc0203de8:	0505                	addi	a0,a0,1
ffffffffc0203dea:	0585                	addi	a1,a1,1
        if (*s1 != *s2) {
ffffffffc0203dec:	fee788e3          	beq	a5,a4,ffffffffc0203ddc <memcmp+0x6>
            return (int)((unsigned char)*s1 - (unsigned char)*s2);
ffffffffc0203df0:	40e7853b          	subw	a0,a5,a4
ffffffffc0203df4:	8082                	ret
    }
    return 0;
ffffffffc0203df6:	4501                	li	a0,0
}
ffffffffc0203df8:	8082                	ret
